Reputation: 31
Where does NSUserDefaults store data in an iOS application.? Is it a good programming practice to assign many NSUserDefaults variables in an application ? or it causes any memory management issues.? When this variables are released.?
Upvotes: 1
Views: 2522
Reputation: 564
Here I share you code, write down in viewDidLoad, you can get the path.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@"%@",paths);
Upvotes: 0
Reputation: 7333
The physical location of NSUserDefaults is :
/Library/Preferences/com.yourcompany.appName.plist
For more information see :
NSUserDefaults class reference
Upvotes: 1
Reputation: 971
It's always preferred to use NSUserDefaults for storing user specific preferences for the application. The values get stored on the device in plist format. You do not need to worry about releasing memory for NSUserDefaults stored data. They are synched with the plist once you call the [[NSUserdefaults ..] synchronize] method.
The only thing you need to worry about is not to use NSUserDefaults for storing sensitive information like passwords. As this plist can be accessed by directly connecting device to mac and accesssing application space (sandbox) using third party softwares available.
Upvotes: 1
Reputation: 620
Users/username/Library/Application Support/iPhone Simulator/5.0/Applications/your app unique id/Library/com.appname
This is the path where the data(NSUserDefaults
) is stored when using Simulator.
When you remove the app from the device the data in the NSUserDefaults will be erased .
Upvotes: 2
Reputation: 286
It stores in the Directory structure of the device. I use NSUSerDefaults to store variables that need not be very secure like username, address etc. For more secure information (eg:password) you would use keychain to store the information.
Upvotes: 2