Created
August 11, 2012 00:28
-
-
Save jcuffe/3319335 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
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
[self registerIntervalHotKey]; | |
NSManagedObjectContext *moc = [self managedObjectContext]; | |
Interval *interval = [NSEntityDescription insertNewObjectForEntityForName:@"Interval" inManagedObjectContext:moc]; | |
interval.startTime = [NSDate date]; | |
NSError *error = nil; | |
[moc save:&error]; | |
} | |
- (void)registerIntervalHotKey { | |
DDHotKeyCenter *hk = [[DDHotKeyCenter alloc] init]; | |
DDHotKeyTask task = ^(NSEvent *hkEvent) { | |
NSError *error = nil; | |
NSManagedObjectContext *moc = [self managedObjectContext]; | |
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Interval"]; | |
NSArray *results = [moc executeFetchRequest:request error:&error]; | |
Interval *interval = [results lastObject]; | |
NSLog(@"%@", interval.startTime); | |
}; | |
if (![hk registerHotKeyWithKeyCode:21 modifierFlags:(NSControlKeyMask | NSCommandKeyMask) task:task]) { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment