From 118abba104a1eeabc5c449ac86e25a6d87f1954c Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Thu, 7 Aug 2014 12:12:06 +0200 Subject: Added a shared binder instance singleton. This adds a really simple API to set up some bindings without having to keep a binder instance around by hand. If somebody wants to, it’s not a problem to allocate a separate instance and have precise control over its lifetime. --- Framework/MASShortcutBinder.m | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Framework/MASShortcutBinder.m') diff --git a/Framework/MASShortcutBinder.m b/Framework/MASShortcutBinder.m index 1039f64..bf85c41 100644 --- a/Framework/MASShortcutBinder.m +++ b/Framework/MASShortcutBinder.m @@ -27,6 +27,16 @@ } } ++ (instancetype) sharedBinder +{ + static dispatch_once_t once; + static MASShortcutBinder *sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + #pragma mark Registration - (void) bindShortcutWithDefaultsKey: (NSString*) defaultsKeyName toAction: (dispatch_block_t) action -- cgit v1.2.3