Shinichi
Shinichi

Reputation: 505

How to store app settings in iOS, like INI / CONF?

I am starting with iOS programming. I have a question hope you can help.

I have a test app as an rss reader that reads from a URL. For example: abc.com/feed

I want to store some data in a setting file like INI on Windows or CONF on Linux, example:

URL = abc.com/feed
NumberOfItem = 10
Interval = 3 # minus

What kind of file does an iOS app use to store it's settings? Is there any method/class/API/... which supports read/write on it?

P.S. I am using Titanium at Appcelerator.

Thanks so much!

Upvotes: 0

Views: 1109

Answers (4)

YvesLeBorg
YvesLeBorg

Reputation: 9089

I use property lists (.plist), essentially an xml file, that can be read and written by the NSDictionary (and all its variants). For simple settings , as @Tobi suggests, NSUserDefaults. For larger, more complex datasets, i go with .plists. For each class that needs to persist, i create a +(id) loadFromDictionary and -(NSDictionary*) asDictionary method.

Upvotes: 1

mariusLAN
mariusLAN

Reputation: 1205

You can save data in the NSUserDefaults the complete API-Documentation from Apple

To save some kind of data in the NSUserDefaults simply call [[NSUsererDefaults standardUserDefaults] setObject:myObject forKey:@"myObjectKey"].

To read the data call [[NSUserDefaults standardUserDefaults] objectForKey:@"myObjectKey"]

Upvotes: 1

Tobi Weißhaar
Tobi Weißhaar

Reputation: 1677

If you just want to store simple data you can use NSUserDefaults NSUserDefaults Example

Upvotes: 0

Related Questions