开发者

When should we call ![[self ListController].FetchController performFetch:&error]?

+(void)CoreSetAllBiz : (NSString *) searchTerm{
    [self ListController].FetchController.fetchRequest.predicate=[BNUtilitiesQuick getFinalPredicate:searchTerm];
    [self ListController].FetchController.fetchRequest.sortDescriptors= [FetchClass getMoreSearchDescriptorsForEntity:@"Business" withMainSortKey:[BNUtilitiesQuick sortBasedOn]];
    NSError *error=nil;

    if (![[self ListController].FetchController performFetch:&error]) {
        DLog(@"Unresolved error %@, %@", error, [error userInfo]);
        //abort();
    }
}

I got that function. However, the function is not efficient. Quite often, searchTerm doesn't change. Quite often the predicate doesn't change.

So when should we call ![[self ListController].FetchController per开发者_如何学运维formFetch:&error]?

Should we call that when the managedObjectContext changes? Notice that the data returned will be different even if [self ListController].FetchController.fetchRequest.predicate and [self ListController].FetchController.fetchRequest.sortDescriptors doesn't change because the underlying managedobjectcontext change

Should we call that when either sortDescriptors or predicate changes?

Or does FetchController has some form of internal mechanism when performFetch is no longer needed?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜