iphone - Add a UISegmentedController to navigation bar with NSFetchedResultsController -


I am working with a UITableView , which has its data sent to NSFetchedResultsController . I would like to add UISegmentedControl to my navigation bar, which can toggle the table between displaying all the records and records only where starred == yes .

I have read some other posts that show that one way to do this is to create another NSFetchedResultsController , with NSPredicate Starred == Yes , but it seems that to create a second NSFetchedResultsController starts to rise horribly.

Is there an easy way to do this?

According to the docs not found on NSFetchedResultsController If you take a look at the documentation on fetchRequests property, you will see the following note:

Important: You should not modify the fetch request. For example, you did not change its definition or sorting .

Since the fetchRequest property is read-only, only one option is making the node result controller.

It may be possible that you can change the Word and do some work, but it is usually a bad idea to do stuff that goes explicitly against things to say in Apple's documents Because it can break into future releases.

> And, be careful of time pre-optimization! As long as you do not test it outside and it has been found that the controller receiving the new result is a large display drain, it is not worth trying to do anything without any recommended method.

New results on the results controller of my results FetchedResultsController is a property of my visual controller, a private invention of Videon View Controller.

I had the code to make the already asked result controller, so to decide that it is about removing the cache.

  - (zero) setproduct: (NSPredicate *) newPredicate {predicate = [newPredicate copy]; // Be sure to remove the cache // (when you have created the result result controller, then using the name from) [NSFetchedResultsController deleteCacheWithName: @ "root"]; // Get the old results Controller self.fetchedResultsController = Zero; // TODO: Handle error! // This result will be made with the newcomer controller [self.fetchedResultsController performFetch: nil]; [Self.tableViewReloadData]; }  

If this code is based on boilerplate XCode, then when you start using a core data, you generate a project.

  - (NSFetchedResultsController *) fetchedResultsController {if (FetchedResultsController! = Zero) {fetchedResultsController; } // Create a fetch request for the organization. NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; // Edit the name of the entity as the proper name NSEntityDescription * entity = [NSEntityDescription EntityForName: Managed object contact in [MyEntity entityName]: Managed object contexts]; [FetchRequest Set Entity: Entity]; [FetchRequest set FetchBatchSize: 20]; NSSortDescriptor * sortDescriptor = [[NSSortDescriptor alloc] initWithKey: @ "Name" climbs: yes]; NSArray * sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, zero]; [Set FetchRequestSercript: Sort Descriptor]; [FetchRequest set candidate: count]; For the section name key path // zero means "no section" NSFetchedResultsController * aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest Managed object contact: managed object contact section nick path: zero cachename: @ "root"]; AFetchedResultsController.delegate = self; Self.fetchedResultsController = Affected Results Controller; [Affected Results Controller Release]; [FetchRequest release]; [Sortedipitre release]; [Sort descriptor release]; Returned Result Controller; }  

Comments