I have this working code, but now i need to be able to change the NSPredicate, based on the object used in the predicateWithFormat as follows:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Item" inManagedObjectContext:_context];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"self.atrObj == %@", _currentUser.atrObj.objectID]];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortContent = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortContent]];
[fetchRequest setFetchBatchSize:10];
NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:_context sectionNameKeyPath:nil
cacheName:nil];
self.fetchedResultsController = theFetchedResultsController;
self.fetchedResultsController.delegate = self;
I need the fetchedResultsControlelr to use the new _currentUser object when i change the _currentUser object from the app delegate which has this tableviewcontroller a property.
[self.tableViewcontroller setCurrentUser:user];
Thank you!
You can change the predicate anytime but be sure to re-fetch via
performFetch. Also from Apple docs:Also, from the Apple docs of
NSFetchedResultsController: