Below in asyncReloadAndMoveToEnd, we reference conversation which is an instance variable.
In order to access the conversation.messages, do we need to be retrieving that object via the objectID via a separate managed context.
- (void) reloadTable {
[self.tbl reloadData];
}
- (void) asyncReloadAndMoveToEnd {
// is this the right way since it's in a separate thread?
NSArray* messages = [conversation.message allObjects];
[self performSelectorOnMainThread:@selector(reloadTable) withObject:nil waitUntilDone:NO];
}
- (void) reload:(bo开发者_Python百科ol) inMoveToEnd {
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(asyncReloadAndMoveToEnd)
object:nil];
[queue addOperation:operation];
}
If you are trying to fetch ManagedObjects for display in a UITableView, NSFetchedResultsController is strongly recommended. It handles storage, caching, and all of the general heavy lifting.Ray Wenderlich has a great tutorial on its use.
精彩评论