Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Saving content to UserDefault
#pragma mark - User Defaults
//Saves information on cache
+ (void)saveToUserDefault:(NSObject*)objectToSave withKey:(NSString*)key {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:objectToSave forKey:key];
[userDefaults synchronize];
//Retrieves information from cache
+ (NSObject*)retrieveFromUserDefaultWithKey:(NSString*)key {
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
//Clears all cache (used on logout for example)
+ (void)clearUserDefault {
[AppUtils saveToUserDefault:nil withKey:API_TOKEN];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.