In my app, I have a simple ASCII file which stores some config info and other small info which it uses and changes. I want to copy that file to the iPhone with the app.
1) Please tell me where I should put this file (config.txt) in xcode. Should I put it under Resources ?
2) How will I access it in the iPhone ? Can I just use
str = [NSString stringWithContentsOfFile:@"config.txt"]
or do I have to use a more complete path; if yes, what is that ?
You should use
NSUserDefaultsto store user settings, if the application can change them.The documentation is here.
The settings are stored as a plist file, so you can store
NSDictionaryinstances,NSArrayinstances, etc.If you want to pre-populate your
NSUserDefaultswith some settings, you can do so with some code like this one:You need to put a defaults.plist file on your Resources folder with the default settings, and use the code above. I run that code from the AppDelegate’s
+(void)initializemethod, but you can choose another place to call it.