iphone – NSUserDefaults physically data – Education Career Blog

I’m wondering if there’s anywhere i can see what data is in my NSUserDefaults? Like, how does it works? Is there a file that stores in my iphone that contains all the data in the NSUserDefaults or is the file stores in different apps? If i have set NSUserDefaults standardUserDefaults setObject:someString forKey:@"someString"; in app A, can i use NSString *listData = NSUserDefaults standardUserDefaults stringForKey:@"someString" to get the string in another app B? Is there somewhere the NSUserDefaults is physically stored?


The preferences of your app are stored in a .plist file (in binary format) in APP_BASE_DIR/Library/Preferences/.

See ~/Library/Application Support/iPhone Simulator/4.1/Applications to see the app base dirs in the iPhone Simulator.


The NSUserDefaults is stored in a plist file; on the iPhone and iPad, you cannot simply open these files.
However, you can have your app print out the contents to the debugger.


I believe sandboxing will prevent accessing another application’s user defaults under iOS. Under Mac OS X, you can work with another application’s user defaults by dropping down to the CFPreferences API:

/* ownership follows the Create/Copy rule, so must release when done -
 * here, I just autorelease */
NSString *
value = (id)CFPreferencesCopyAppValue(CFSTR("key"), CFSTR("com.foo.otherapp"))
if (value isKindOfClass:NSString class) {
    /* use the string */

Leave a Comment