Created
October 25, 2012 15:28
-
-
Save ipodishima/3953339 to your computer and use it in GitHub Desktop.
Enqueue notification when run loop is idle
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
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