-
Notifications
You must be signed in to change notification settings - Fork 1
/
MYSReady.m
49 lines (38 loc) · 878 Bytes
/
MYSReady.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
//
// MYSReady.m
// FirehoseChat
//
// Created by Adam Kirk on 10/4/14.
// Copyright (c) 2014 Adam Kirk. All rights reserved.
//
#import "MYSReady.h"
@implementation MYSReady
+ (instancetype)sharedReadyForActionName:(NSString *)actionName
{
static NSMutableDictionary *__objects;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__objects = [NSMutableDictionary new];
});
if (!__objects[actionName]) {
__objects[actionName] = [MYSReady new];
}
return __objects[actionName];
}
- (void)setObject:(id)object
{
_object = object;
if (self.actionBlock) {
self.actionBlock(object);
_object = nil;
}
}
- (void)setActionBlock:(void (^)(id object))actionBlock
{
_actionBlock = actionBlock;
if (self.object) {
actionBlock(self.object);
_object = nil;
}
}
@end