Skip to content

Instantly share code, notes, and snippets.

@software-mariodiana
Last active August 29, 2015 14:02
Show Gist options
  • Save software-mariodiana/3bbeb633c055881d6bc5 to your computer and use it in GitHub Desktop.
Save software-mariodiana/3bbeb633c055881d6bc5 to your computer and use it in GitHub Desktop.
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();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment