Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing iPhone application settings in app

Tags:

My iPhone app has few settings that users is likely to change quite often. I would like to know if there's any suggested way of handling such settings (reading and saving them). On Apple sites I found only a tutorial about integrating your application settings with Settings app (link) but I don't want a user to exit my app so he could just change the option.

Is there any default mechanism to handle such settings in app itself or do I have to implement a solution of my own?

like image 259
RaYell Avatar asked Feb 09 '10 10:02

RaYell


People also ask

How do I organize my iPhone apps in settings?

Touch and hold the Home Screen background until the apps begin to jiggle. To create a folder, drag an app onto another app. Drag other apps into the folder. You can have multiple pages of apps in the folder.

Is there a faster way to organize iPhone apps?

Quickly reorder your iPhone, iPad home screen Start to drag one of the app icons to an empty spot on your screen. With your finger still on the app icon, start tapping on the rest of the apps you want to relocate. As you tap on the icons, your iPhone or iPad will create a stack of apps that you're moving.

How do I manage app storage on iPhone?

Go to Settings > General > [Device] Storage. You might see a list of recommendations for optimizing your device's storage, followed by a list of installed apps and the amount of storage each one uses. Tap an app's name for more information about its storage.

Can you organize your iPhone apps on your computer?

iTunes lets you rearrange the order of the apps on your Home screens (as shown above), as well as the Home screens themselves (on the right side of the window), just by clicking-and-dragging. So, if you have a lot of arranging to do, just connect your iPhone to your computer and select it in the iTunes Source list.


2 Answers

Best and easiest way to store settings in the iPhone is through NSUserDefaults. Keeps you from having to deal with the file system or plists or any of that other stuff.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];  NSString *storedVal = @"This is what you want to save"; NSString *key = @"storedVal"; // the key for the data  [defaults setObject:storedVal forKey:key]; [defaults synchronize]; // this method is optional   // Get the results out NSString *results = [defaults stringForKey:key]; 

Here's what Apple says on the types of objects you can store in the Defaults

A default object must be a property list, that is, an instance of (or for collections a combination of instances of): NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. If you want to store any other type of object, you should typically archive it to create an instance of NSData.

There are some more caveats, like if you store an NSDictionary the key values must be strings.

like image 152
kubi Avatar answered Oct 09 '22 22:10

kubi


If you're looking for a UI to edit the settings from inside the app, check out InAppSettingsKit at http://www.inappsettingskit.com

like image 34
Ortwin Gentz Avatar answered Oct 09 '22 22:10

Ortwin Gentz