I have just started building applications with CoreData, but I am familiar with the concepts of MVC because I did a lot of web development work using (and developing) MVC frameworks.
From what I am compiling, CoreData automatically generates classes that inherit from NSManagedObject. Objects are created by querying a selection in a context or by inserting a new one into a context. In the applications that I saw, objects are empty, except for properties that match their attributes in the database, which makes them objects that mimic a row in an entity table.
It makes sense that auto-generated classes and CoreData make up the application model. In the applications that I have done traditionally, instead there is a Model class that is responsible for processing all the data. This is often a Singleton class, and every controller that needs a model can simply use self.model = [Model sharedInstance]; . For large applications, there may be several models, rather than one giant. You will get a picture. I think my first question is: am I right? Does CoreData and its associated NSManagedObject make up the entire model for the application?
I would suggest that this is wrong, because the application might require other functionality that deals with data that does not have an assigned CoreData object. For example: what if a CoreData application needs to populate a table view with data that is retrieved through an HTTP request from foo.com/test (say, this is JSON data). This data does not need to be stored in CoreData, but at the same time, I do not think that obtaining and analyzing data is a task for the controller. If there is an object, FooDataManager (or something like that) that processes HTTP requests to manage data from foo.com (it can extend AFHTTPClient). And then the controllers dealing with foo.com have a property for FooDataManager that acts like a model for this controller? And then the controllers will call [self.fooDataManager retrieveAndParseData]; ?
I want to check this information before starting to develop CoreData applications so that I do it right from the very beginning. In web development, I'm used to having one model for each controller, but it seems like on iOS, there can be many models that do everything themselves, many controllers that use these models, and all these models are in addition to CoreData and NSManagedObjects.
source share