Core Data Design Pattern
I am trying to work out the best way to integrate Core Data into my app. I have read through the Core Data Programming Guide and I have a decent idea on how to use it but all of the examples I have seen use Core Data requests like Fetch or Insert in ViewControllers. I'd really like some way to increase how much code I reuse, like all good programmers should, but I am having trouble doing this.
My current idea is to sub-class the Managed Objects that are created from the Object Model and put common tasks in there like creating, fetching, saving and deleting objects (pretty much all of the standard CRUD operations) so that I can use them all over my app in different view controllers.
Has anyone been able to get this sort of approach to work or am I trying to fit a square block on a round hole?
I really don't like the idea of having to call methods like insertNewObjectForEntityForName multiple times in multiple places. I should be able to have a single object do it for me.
|