"passing managedobjectcontext along to view/controller hierarchy" Code Answer

2

the recommended design is to do a dependency injection. this means that when you create a uiviewcontroller you pass in the nsmanagedobjectcontext via a property. if the uiviewcontroller only needs a single or set of nsmanagedobject instances then you would just hand those in via properties.

this design is more flexible and allows for greater reuse of your code. linking everything to a single "hard-coded" nsmanagedobjectcontext in the appdelegate is fragile and reduces the flexibility of your code.

i discuss this in depth on the mac developer network. (edit: lost link now via wayback machine's cache)

By prudhvi on April 30 2022

Answers related to “passing managedobjectcontext along to view/controller hierarchy”

Only authorized users can answer the Search term. Please sign in first, or register a free account.