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 -
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/AtomicStore_Concepts/Articles/asLoading.html#//apple_ref/doc/uid/TP40005298
Please let me know if this makes sense or if there's a better way to handle this.
Have you read through:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
Also check out TBXML:
TBXML is a light-weight XML document parser written in Objective-C designed for use on Apple iPad, iPhone & iPod Touch devices. TBXML aims to provide the fastest possible XML parsing whilst utilising the fewest resources. This requirement for absolute efficiency is achieved at the expense of XML validation and modification. It is not possible to modify and generate valid XML from a TBXML object and no validation is performed whatsoever whilst importing and parsing an XML document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With