forked from haxpor/Potatso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.m
46 lines (37 loc) · 964 Bytes
/
Settings.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
41
42
43
44
45
46
//
// Settings.m
// Potatso
//
// Created by LEI on 7/13/16.
// Copyright © 2016 TouchingApp. All rights reserved.
//
#import "Settings.h"
#import "Potatso.h"
#define kSettingsKeyStartTime @"startTime"
@interface Settings ()
@property (nonatomic, strong) NSUserDefaults *userDefaults;
@end
@implementation Settings
+ (Settings *)shared {
static Settings *settings;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
settings = [Settings new];
});
return settings;
}
- (instancetype)init {
self = [super init];
if (self) {
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName: [Potatso sharedGroupIdentifier]];
}
return self;
}
- (void)setStartTime:(NSDate *)startTime {
[self.userDefaults setObject:startTime forKey:kSettingsKeyStartTime];
[self.userDefaults synchronize];
}
- (NSDate *)startTime {
return [self.userDefaults objectForKey:kSettingsKeyStartTime];
}
@end