Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ist it a good idea to use NSUserDefaults to store the latest state of an iPhone application?

I have an view-based application where the user can do a lot of customization things, like selecting colors, selecting pictures, and so on.

First, I thought about using sqlite3 for that, but since this would result in a table with only one row (no multi-user app), it seems like a big overhead to me. Then I heard about NSUserDefaults. But I am not sure where this data is stored. Is it stored in the app's sandbox? Or is it stored somewhere else? Do other apps have access to that data? Is it good for remembering this kind of customization stuff?

like image 680
Thanks Avatar asked Dec 23 '22 11:12

Thanks


1 Answers

The NSUserDefaults class is meant for storing user preferences for your application. It's stored in a plist file in the application's sandbox Library directory.

[[NSUserDefaults standardUserDefaults] setObject:@"Test" forKey:@"myPref"];
NSString *val = [[NSUserDefaults standardUserDefaults] stringforKey:@"myPref"];
like image 162
Jason Harwig Avatar answered Jan 31 '23 07:01

Jason Harwig