Reputation: 592
I have a question about application rigidity, because Apple in doc says that
This makes the application architecture rigid
I can agree with that. Every uiviewcontroller should be... not dependable on current flow of application, but UIApplication delegate is rather constant, you always can call to that delegate.
Second argument that I heard about nsmanagedobjectcontext is dependency injection. Every object should has only objects that really need, but what if you have to pass managedobjectcontext by few controllers that don't need them but they are placed between desired controller and source controller, it is not actually dependency injection and better solution is I suppose singleton.
What do you think about that? Maybe you have other ideas for passing managedobjectcontext over controllers?
Upvotes: 1
Views: 871
Reputation: 80273
There is nothing wrong in principle with a singleton providing the managed object context. If you are going to use just one context in your app, it really does not matter.
However, if you are doing background fetches and saves, and if you use the core data concurrency methods with parent-child contexts, this approach quickly becomes problematic.
Upvotes: 1