Skip to content

Instantly share code, notes, and snippets.

@ipodishima
Created October 25, 2012 15:28
Show Gist options
  • Save ipodishima/3953339 to your computer and use it in GitHub Desktop.
Save ipodishima/3953339 to your computer and use it in GitHub Desktop.
Enqueue notification when run loop is idle
NSNotification *idleNotif = [NSNotification notificationWithName:NotificationCleanUpOnIdle object:nil];
[[NSNotificationQueue defaultQueue] enqueueNotification:idleNotif postingStyle:NSPostWhenIdle];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSystemIdle:) name:NotificationCleanUpOnIdle object:nil];
// ....
- (void) onSystemIdle:(NSNotification*)notification
{
// Clean up database in a separate thread for example
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment