views:

270

answers:

0

I'm doing design for a project and nothing's been implemented - so I'm still going through the thought process to determine if Core Data is viable for the project.

Here's my query -

I want to create a managed object model using Core Data to represent some server side objects e.g Folder, File, etc.... All the objects (Folder, File etc..) are accessible via XMLRPC APIs that return some well formed XML.

For example, there may be an API called getFolders that can return the following -

<xml>
 <folders>
  <folder id=1>
    <name>Test 123</name>
   <files>
      <file id=100>
           <name>hello.txt</name>
          <path>./hello.txt</path>
      </file>
      ...
  </files>
 </folder>
 ...
</folders>

Similarly there can be an updateFolders API that operates on an existing folder item and for simplicity lets say it just updates the folder name. The request for it would post something like the following -

<xml>
 <method name="updateFolder">
  <folder_id="1">
  <params>
   <param name="folder_name" value="Test"/>
  </params>
 </method>

I'm trying to figure out -

  1. How can I represent folder as a managed object i.e., how do I initialize it from the above XML
  2. Once initialized, how can I handle an update to it using the updateFolder API shown above

It seems like the NSPersistentStore such as XMLStoreType point directly to actual XML files that hold the final data. In my case, the XML is simply whats returned from an XMLRPC call and the actual data is stored on a server side DB. Therefore, since the stores are not direct representations of the objects (or where the objects are stored), I was wondering if I should create a custom NSAtomicStore and handle load and save for initialization and update respectively. Here's a link on doing this for a NSAtomicStore -

http://devworld.apple.com/documentation/Cocoa/Conceptual/AtomicStore%5FConcepts/Articles/asLoading.html#//apple%5Fref/doc/uid/TP40005298

Please let me know if this makes sense or if there's a better way to handle this.

Thanks in advance for your help!