forked from shiftcmdk/AutoAlerts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAAAlertManager.m
74 lines (55 loc) · 1.67 KB
/
AAAlertManager.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#import "AAAlertManager.h"
#import "AADataStore.h"
#import "AACoreDataStack.h"
@interface AAAlertManager ()
@property (nonatomic, retain) id<AADataStore> store;
-(id)initWithDataStore:(id<AADataStore>)store;
@end
@implementation AAAlertManager
-(id)initWithDataStore:(id<AADataStore>)store {
if (self = [super init]) {
self.store = store;
}
return self;
}
+(instancetype)sharedManager
{
static AAAlertManager *sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
id store = [[[AACoreDataStack alloc] init] autorelease];
sharedManager = [[AAAlertManager alloc] initWithDataStore:store];
});
return sharedManager;
}
-(void)saveAlert:(AAAlertInfo *)alert error:(NSError **)error {
[self.store saveAlert:alert error:error];
}
-(void)updateAlert:(AAAlertInfo *)alert error:(NSError **)error {
[self.store updateAlert:alert error:error];
}
-(void)deleteAlert:(AAAlertInfo *)alert error:(NSError **)error {
[self.store deleteAlert:alert error:error];
}
-(void)deleteAlertWithID:(NSString *)identifier error:(NSError **)error {
[self.store deleteAlertWithID:identifier error:error];
}
-(void)deleteAlertsWithBundleID:(NSString *)bundleID error:(NSError **)error {
[self.store deleteAlertsWithBundleID:bundleID error:error];
}
-(AAAlertInfo *)alertWithID:(NSString *)alertID {
return [self.store alertWithID:alertID];
}
-(NSArray<AAAlertInfo *> *)allAlerts {
return [self.store allAlerts];
}
-(void)initialize {
if ([self.store respondsToSelector:@selector(initialize)]) {
[self.store initialize];
}
}
-(void)dealloc {
self.store = nil;
[super dealloc];
}
@end