Created
September 17, 2014 17:51
-
-
Save objectiveSee/f46d8e0a857288c4d3a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DRBlocks.h" | |
@interface DRBlocks () | |
@property (nonatomic) NSMutableDictionary *blocksHash; | |
@end | |
@implementation DRBlocks | |
- (instancetype)init | |
{ | |
self = [super init]; | |
if (self) { | |
self.blocksHash = [NSMutableDictionary new]; | |
} | |
return self; | |
} | |
- (instancetype)sharedBlocks { | |
static DRBlocks *blockSingleton = nil; | |
static dispatch_once_t predicate; | |
dispatch_once(&predicate, ^{ | |
blockSingleton = [[DRBlocks alloc] init]; | |
}); | |
return blockSingleton; | |
} | |
- (void)addBlock:(NSObject *)block forKey:(NSString *)key { | |
if ( block ) { | |
[self.blocksHash setObject:[block copy] forKey:key]; | |
} | |
} | |
- (NSObject *)getBlockForKey:(NSString *)key { | |
return [self.blocksHash objectForKey:key]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment