Instantiating an array by loading a plist file asynchronously, and using a block to notify the associated UITableView to reload its data.
/*
* Assume the following:
*
* - The Plist file is called: Names.plist
* - @property NSArray *tableData
* - Callback block messages UITableView with reloadData
*/
- (void)initizeDataWithTableViewCallback:(void(^)(void))reloadDataMessage
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *path = [[NSBundle mainBundle] pathForResource:@"Names" ofType:@"plist"];
self.tableData = [NSArray arrayWithContentsOfFile:path];
dispatch_async(dispatch_get_main_queue(), ^{
// Tell the UITableView to reload its data.
reloadDataMessage();
});
});
}