Core Data: UIManagedDocument vs AppDelegate's managedObjectContext @property

846 Views Asked by At

There are two ways to get a NSManagedObjectContext that I know of:

  1. create a UIManagedDocument and ask for its managed object context

  2. access the AppDelegate's managedObjectContext @property.

What are the trade-offs here? I've been doing it the UIManagedDocument way, but I can't seem to find an explanation anywhere on when/why you'd choose one over the other. Any clarification would be greatly appreciated!

1

There are 1 best solutions below

2
On BEST ANSWER

Use UIManagedDocument if you're arranging data in a manner that the user perceives as a "document"'s worth of data. If you are not, then you could use UIManagedDocument or the AppDelegate mechanism interchangeably.