Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Core Data is not nearly as complicated as you describe.</p> <p>Generally, an iPhone app has a "main" managed object context, which is generally owned by the app delegate. So long as you can get the app delegate (hint: <code>[[UIApplication sharedApplication] delegate]</code>) you have access to the managed object context. I like to define a static global variable to hold a reference to my app delegate to make life easier.</p> <p>There's generally a one-to-one correspondence between <code>NSFetchedResultsController</code> instances and <code>UITableView</code> instances. Aside from populating table views, it's exceedingly rare that you would need an <code>NSFetchedResultsController</code>. If you have a number of similar views (e.g. a tab bar that lets you view the same data in different ways a la the iPod app), it would behoove you to create a single base class that configures the <code>NSFetchedResultsController</code> and derive your specific view controllers from that.</p> <p>Now, when you create view controllers to edit an object, it's generally a good idea to do that in a separate managed object context. If the user cancels, you just discard the context and the changes go away. Again, you don't really need an <code>NSFetchedResultsController</code> for this because these views are only concerned with a single object.</p> <p>When you're done editing, you <code>save:</code> the managed object context. The objects that manage your other managed object contexts should implement the <code>NSFetchedResultsControllerDelegate</code> methods to keep the table view in sync. Again, this can be implemented in a base class so you can generalize this functionality for related view controllers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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