Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created August 11, 2012 00:28
Show Gist options
  • Save jcuffe/3319335 to your computer and use it in GitHub Desktop.
Save jcuffe/3319335 to your computer and use it in GitHub Desktop.
- (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