iOS Core Data Architecture tips wanted

后端 未结 3 1721
离开以前
离开以前 2021-02-09 11:09

I just want to get a few pointers on the best way to architect my first Core Data app, and the main objects and interactions I will require.

The data is stored remotely

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-09 11:48

    There are a lot of different pieces at play here. Allow me to make some suggestions:

    1. For fetching the data from the server, I would look at ASIHTTPRequest. This is a good solution for managing your HTTP requests (whether you are using JSON, XML, or whatever..). http://allseeing-i.com/ASIHTTPRequest/
    2. For JSON translation, I would look at SBJSON. The site has documentation on how to get started: http://code.google.com/p/json-framework/
    3. For your overall architecture, I would implement a delegate pattern that wraps your service calls. In this delegate, you would handle the translation of the JSON data to actual Objective-C classes before the data gets passed to the rest of the application.
    4. Once the data is parsed and placed into Objective-C objects (and I would have these objects be subclasses of NSManagedObject which ties to your data model directory), I would perform a save.
    5. I would then use an NSNotification to inform the needed views that the data has changed.

提交回复
热议问题