开发者

Do you have to use objectWithID when the instance variable is already retrieved?

开发者 https://www.devze.com 2023-03-31 17:29 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消