开发者

iPad: CoreData FetchedRequest Ignores Changes in Predicate

While programming an iPad-app, I'm just running into trouble using a fetchedResultsController with a "dynamic" predicate. it seems the changes to the predicate get ignored. No matter how the predicate changes, I alway开发者_高级运维s get the result of the first fetch ...

same code runs without no problems on iphone-env (3.1.x) !!

sample :

- (void)performSearch:(NSString *)searchText {
  self.displaySearchResults = TRUE;
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"searchWords contains[cd] %@", searchText];
  [self.fetchedSearchResultsController.fetchRequest setPredicate:predicate];

  NSError *error = nil;
  if (![self.fetchedSearchResultsController performFetch:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
  }

  if(deviceIsIPad) {
    [self showSearchResults];
  }  
  else {
    [cookBookOverview reloadData];
  }
}

can anyone help plz ?

btw.: excuse my painful english ;-)


You must clear cache all time when you change predicate or fetchRequest

    // clear cache
[NSFetchedResultsController deleteCacheWithName:@"CacheName"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜