开发者

iPad: CoreData FetchedRequest Ignores Changes in Predicate

开发者 https://www.devze.com 2023-01-01 22:08 出处:网络
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 predic

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

精彩评论

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