diff options
| author | Teddy Wing | 2016-12-01 06:58:56 -0500 |
|---|---|---|
| committer | Teddy Wing | 2016-12-01 06:58:56 -0500 |
| commit | a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf (patch) | |
| tree | a5a0751d2f53d0ab4e16a2f33a808c6df28f0bc5 /Low Battery Yup/AppDelegate.m | |
| parent | db87cb37fabb7ddddfc4a3472a351ca35be64e75 (diff) | |
| download | Low-Battery-Yup-a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf.tar.bz2 | |
Able to get a shortcut from the MASShortcutView
Fuck damn it finally freaking works! Damn, just had to take a 1.5 hour
nap after that.
We're finally able to extract a shortcut out of the MASShortcutView.
After trying a whole bunch of different things, I ultimately tried
opening the debugger and figured out that for whatever reason the
bindings weren't getting created and because of that my shortcut wasn't
getting saved in the user defaults.
Couldn't figure out how to get the binding to work even after includes
and whatnot.
Finally decided screw it I'm going to subclass the view and get the
shortcut and store it in `NSUserDefaults` myself. So that's what we're
going to do and this is the first step to getting that working.
Hoo boy.
Definitely need to vaccum the code after this.
Diffstat (limited to 'Low Battery Yup/AppDelegate.m')
| -rw-r--r-- | Low Battery Yup/AppDelegate.m | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index 0c9bbdc..8a9005f 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -8,6 +8,9 @@ #import "AppDelegate.h" +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; +static void *AppObservingContext = &AppObservingContext; + @implementation AppDelegate - (void)dealloc @@ -17,7 +20,35 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application + [_shortcut_view setAssociatedUserDefaultsKey:kPreferenceGlobalShortcut]; + +// NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; +// [_shortcut_view bind:@"shortcutValue" toObject:defaults withKeyPath:@"thisisatest" options:nil]; + +// [defaults addObserver:self forKeyPath:@"thisisatest" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:AppObservingContext]; + +// [[MASShortcutBinder sharedBinder] +// bindShortcutWithDefaultsKey:kPreferenceGlobalShortcut +// toAction:^{NSLog(@"dudebro");}]; + +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + NSLog(@"OBSERVED"); + NSLog(@"%@", change); +} + +- (IBAction)logDefaults:(id)sender +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSLog(@"%@", [defaults objectForKey:[@"values." stringByAppendingString:kPreferenceGlobalShortcut]]); +// NSLog(@"%@", [defaults objectForKey:kPreferenceGlobalShortcut]); +// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]); + +// NSLog(@"%@", [_shortcut_view shortcutValue]); +// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"thisisatest"]); +// [[NSUserDefaults standardUserDefaults] setObject:@"dude come on" forKey:@"thisisatest"]; } @end |
