Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (29 sloc) 1.032 kb

Having Persistent Application State

NMCLient provides faculties for storing persistent application state into the NSUserDefaults without the any hassle with sync inline
Use currentUser as a key-value store in your app

Set an arbitrary string

NSString *_key = @"the-key-for-this";
[[NMUtil currentUser] setString:@"some value that should persist" forKey:_key];
Get it back later
NSString *importantValue = [[NMUtil currentUser] getStringForKey:_key];
Store the date of the last update of some item to NOW
NSString *dateKey = @"some-date-key-name";
[[NMUtil currentUser] setDate:[NSDate date] forKey:dateKey];
Get that date back later.
NSDate *last_update = [[NMUtil currentUser] getDateForKey:dateKey];
Store boolean values and test for certain states at app launch
NSString *yesKey = @"yes";
[[NMUtil currentUser] setBoolean:YES forKey:yesKey];
BOOL yesOrNo = [[NMUtil currentUser] getBooleanForKey:yesKey];
Jump to Line
Something went wrong with that request. Please try again.