-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserDefaultsManager.m
40 lines (31 loc) · 1.09 KB
/
UserDefaultsManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// UserDefaultsManager.m
//
// Created by Toma Popov on 1/23/15.
// Copyright (c) 2015 . All rights reserved.
//
#import "UserDefaultsManager.h"
NSString * const kTimeOfLastLocalFileCleanUpKey = @"kTimeOfLastLocalFileCleanUpKey";
@implementation UserDefaultsManager
+ (id)sharedManager {
static UserDefaultsManager *userDefaultsManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
userDefaultsManager = [[UserDefaultsManager alloc] init];
});
return userDefaultsManager;
}
- (NSDate *)timeOfLastLocalFileCleanUp {
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
return [userDefaults objectForKey:kTimeOfLastLocalFileCleanUpKey];
}
- (void)setTimeOfLastLocalFileCleanUp:(NSDate *)date {
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
if (![date isKindOfClass:NSDate.class]) {
[userDefaults removeObjectForKey:kTimeOfLastLocalFileCleanUpKey];
} else {
[userDefaults setObject:date forKey:kTimeOfLastLocalFileCleanUpKey];
}
[userDefaults synchronize];
}
@end