Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I second Brad's comment, but I'll give you some pointers:</p> <ol> <li><p>Basically yes, you need a new NSFetchedResultsController for every entity you want to query for. However, you don't need to use and NSFetchedResultsController at all, this is just a nice class to let you do fancy things with your tableView as you are doing in question #2.</p></li> <li><p>Your problem here is that you are calling <code>[NSEntityDescription insertNNewObjectForEntityForName:@"Entity" inManagedObjectContext:context_];</code> from your tableViewController and as soon as you call that your NSFetechedResultsController will get a message stating that a row was inserted, triggering the NSFetchedResultsChangeInsert path in your <code>controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:</code> method. NSFetchedResultsController is an object that watches the data that is fetches from CoreData for any changes and then gives you the ability to do stuff as the changes happen. To fix your display issue, just move the insertNewObjectForEntityName call into your next viewController, and magically when you dismiss that viewController you'll have a new row.</p></li> <li><p>The didChangeSection: delegate method of NSFetchedResultsController is informing you if a section has been added or deleted from your dataset. See my answer to #4 and this should be clear.</p></li> <li><p>NSFetechedResultsController allows you to "section" the data it fetches using the sectionNameKeyPath: part of the init call. By supplying the name of a data point in your entity you can group your data into sections. So going back to #3 &amp; #2 if you happen to insert a new entity that has a new value in the "section" keypath that you specified when initing the NSFetchedResultsController you'd get the didChangeSection: delegate called.</p></li> </ol> <p>I recommend reading Apples documentation on <a href="http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html" rel="nofollow">NSFetchedResultsController</a> and <a href="http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html#//apple_ref/doc/uid/TP40001075" rel="nofollow">CoreData</a> and probably their <a href="http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html" rel="nofollow">TableView Programming Guide</a>. Don't forget to download and play with the sample code, it's easier to understand in most cases than the theories in the documentation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload