views:

113

answers:

1

Hi there,

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 always 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 ;-)

A: 

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

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