I am using NSUserDefaults to store some data in my application.
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:@"dummy string" forKey:@"lastValue"]; [prefs synchronize];
For testing purposes I need to see the System Preferences plist file where my NSUserDefaults data is saving on the Mac.
I know where the iOS application user defaults are stored, but I don't know about mac application. Where is a Mac Application's NSUserDefaults Data Stored?
All the contents saved by NSUserDefaults is saved inside a plist file that can be found under Library -> Preferences -> $AppBundleId.
Types stored in NSUserDefaultsplist type can be stored by NSUserDefaults . These types are NSString(String) , NSArray(Array) , NSDictionary(Dictionary) (for both NSArray and NSDictionary types their contents must be property list objects), NSNumber(Int, Float, Double, Boolean) , NSDate and NSData .
static func setObject(value:AnyObject ,key:String) { let pref = NSUserDefaults. standardUserDefaults() pref. setObject(value, forKey: key) pref. synchronize() } static func getObject(key:String) -> AnyObject { let pref = NSUserDefaults.
The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an app to customize its behavior to match a user's preferences. For example, you can allow users to specify their preferred units of measurement or media playback speed.
They can be found in more than one place:
~/Library/Preferences/com.example.myapp.plist ~/Library/SyncedPreferences/com.example.myapp.plist
and if sandboxed
~/Library/Containers/com.example.myapp/Data/Library/Preferences/com.example.myapp.plist ~/Library/Containers/com.example.myapp/Data/Library/SyncedPreferences/com.example.myapp.plist
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With