I’m developing an iPhone application (well, I’m migrating a Windows Phone 7.1 to iPhone), and I have some questions:
Previously, I’ve asked this question, Storing data in XML or SQL?, when I was developing a Windows Phone 7.1 app. And now I have the same question, but in this case it is about iPhone.
I’ve found in iOS development, that XML is not as easy to read as in Windows Phone. In this question, Reading XML attributes and text, you can find what method I’m using to read a XML file.
I’m sure, I don’t need to use a database to store only 22 items, but, is there any other way to store that 22 items? Or, maybe, you know an easy way to read XML.
I need something like this:
<?xml version="1.0" encoding="utf-8" ?>
<cards>
<card id ="0">
<name lang="en">Mad</name>
<description lang="en">This...</description>
</card>
...
</cards>
This data will be readonly: user will never change it. And it will be as file bundled with my app.
You haven’t said how you are using this data.
Are you talking about simply bundling data with your application? If so, the simplest way of doing so is to use a property list (plist). Both
NSArrayandNSDictionaryhave convenience methods to pull arrays and dictionaries straight out of plists, and there is a graphical editor build into Xcode.Are you loading this data over a web service? Do you have to support multiple platforms? If this is the case, then JSON would be a better option. JSON support was only included in iOS 5, but if you need to support earlier versions, JSONKit will handle this for you.
Do you have to update and run queries over the data? Core Data is a better option for this kind of thing. You can preload it with the contents of a plist or JSON file when the user first runs the application.
There are a lot of different options, and unless you provide more detail, it’s difficult to give you good advice.