Quote:
Originally Posted by Code
Hi Guys,
I have a little bit of data that my app needs to function. Not much, so was wondering whats the easiest method of getting this data into my app?
(I'm new to Iphones and objective-c so an easy method would help)
At the moment its stored in a text file but i could change it into an XML file or whatever is needed.
Thanks for your advice.
-Code 
|
Do you want the data to be included in the app, or created on the fly?
Many of the container classes in Cocoa include methods to write their contents to a file, and other methods that will create a new instance of the object with the contents of a file. These methods use "plist" format, and you can control whether it uses a binary plist format or an specific XML format.
For data that's included in the app, you would read it from the app bundle. If you look at the docs for NSBundle there are methods that give you a path to the main bundle. You append a filename to the bundle's path and use that as a path to your file. Bear in mind that the contents of the app bundle are read-only.
You could also use NSUserDefaults, and set default values for those defaults. User defaults let you save data that can change. Again, take a look at the XCode docs on NSUserDefaults. Look at the method registerDefaults for creating default values for user defaults.