Last active
August 29, 2015 14:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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