12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // UserDefaultManager.m
- // FirstLink
- //
- // Created by unicode on 14-11-24.
- // Copyright (c) 2014年 FirstLink. All rights reserved.
- //
- #import "UserDefaultManager.h"
- @implementation UserDefaultManager
- + (UserDefaultManager *)sharedManager {
- static UserDefaultManager *sharedUserDefaultManagerInstance = nil;
-
- static dispatch_once_t once_token;
- dispatch_once(&once_token, ^{
- sharedUserDefaultManagerInstance = [[self alloc] init];
- });
-
- return sharedUserDefaultManagerInstance;
- }
- - (id)getUserDefaultObject:(NSString *)key {
- // return YES;
- NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- return [userDefault objectForKey:key];
- }
- - (BOOL)setUserDefaultObject:(id)object key:(NSString *)key {
- NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- [userDefault setObject:object forKey:key];
- return [userDefault synchronize];
- }
- - (BOOL)removeUserDefaultKey:(NSString *)key {
- if (!key) {
- return FALSE;
- }
-
- NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- [userDefault removeObjectForKey:key];
- return [userDefault synchronize];
- }
- + (BOOL)removeAllDataInUserDefault {
- [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];
- return TRUE;
- }
- @end
|