2

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!

user1181046
  • 327
  • 3
  • 8

1 Answers1

0

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.

user1181046
  • 327
  • 3
  • 8
  • 1
    Sorry for the downvote - but I have the same question and find the answer redundant and unhelpful. Can you expand on "document"'s worth of data? Isn't it necessary to sue UIManagedDocument if you intend to support iCloud? What advantages are there for not using UIManagedDocument, but simple CoreData+SQL? – Rhubarb Mar 19 '12 at 11:48
  • @rhubarb UIManagedDocument and CoreData+SQL are not mutually exclusive. You still use CoreData when using a UIManagedDocument. Using a UIManagedDocument is just another level of abstraction on top of CoreData. If you had a grocery store database, you could have a UIManagedDocument for each grocery store. Hope that explains it! – user1181046 Apr 26 '12 at 20:31