Permalink
Browse files

Fixing a bug with resetting user defaults.

  • Loading branch information...
1 parent c613162 commit ffafb30498445cd5de120b5babab0d55a2e5be6d @shpakovski committed Mar 6, 2013
Showing with 6 additions and 6 deletions.
  1. +2 −2 MASShortcut+UserDefaults.m
  2. +4 −4 MASShortcutView+UserDefaults.m
@@ -41,9 +41,9 @@ + (void)setGlobalShortcut:(MASShortcut *)shortcut forUserDefaultsKey:(NSString *
{
NSData *shortcutData = shortcut.data;
if (shortcutData)
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:userDefaultsKey];
- else
[[NSUserDefaults standardUserDefaults] setObject:shortcutData forKey:userDefaultsKey];
+ else
+ [[NSUserDefaults standardUserDefaults] removeObjectForKey:userDefaultsKey];
}
@end
@@ -15,22 +15,22 @@ - (id)initWithShortcutView:(MASShortcutView *)shortcutView userDefaultsKey:(NSSt
@implementation MASShortcutView (UserDefaults)
-void *kDefaultsObserver = &kDefaultsObserver;
+void *MASAssociatedDefaultsObserver = &MASAssociatedDefaultsObserver;
- (NSString *)associatedUserDefaultsKey
{
- MASShortcutDefaultsObserver *defaultsObserver = objc_getAssociatedObject(self, kDefaultsObserver);
+ MASShortcutDefaultsObserver *defaultsObserver = objc_getAssociatedObject(self, MASAssociatedDefaultsObserver);
return defaultsObserver.userDefaultsKey;
}
- (void)setAssociatedUserDefaultsKey:(NSString *)associatedUserDefaultsKey
{
// First, stop observing previous shortcut view
- objc_setAssociatedObject(self, kDefaultsObserver, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ objc_setAssociatedObject(self, MASAssociatedDefaultsObserver, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
// Next, start observing current shortcut view
MASShortcutDefaultsObserver *defaultsObserver = [[MASShortcutDefaultsObserver alloc] initWithShortcutView:self userDefaultsKey:associatedUserDefaultsKey];
- objc_setAssociatedObject(self, kDefaultsObserver, defaultsObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ objc_setAssociatedObject(self, MASAssociatedDefaultsObserver, defaultsObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end

0 comments on commit ffafb30

Please sign in to comment.