views:

115

answers:

1

Hi,

I'm trying to design a simple Cocoa application and I would like to have a clear and easy to understand software architecture. Of course, I'm using a basic MVC design and my question concerns the Model layer. For my application, the Model represents data fetched on the Internet with a XML-RPC API. I'm planning to use Core Data to represent a locally fetched version. How should the data be loaded initially? I'm reading the Cocoa Design Pattern book, and they talk about a Model-Controller that is centric to the Model. How would that be done?

Thanks!

A: 

Your question is sort of open ended so I will give you my take as someone who has gone through the process of redesigning a poorly built application.

The idea for your model is quite simple:

  1. Create a Data Model (this involves creating your Entities, their properties and relationships).
  2. Put code in place to create a Managed Object Context using the Data Model created in step 1.
  3. Fetch your data from the Internet and create NSManagedObjects based on your Data Model

After step three you will have a Core Data representation of your model in memory, which you can use to drive your user interfaces, or save to a persistent store (to file).

The Core Data documentation, covers each one of the above steps in further detail.

alyx