Created
July 1, 2012 21:57
-
-
Save ksm/3029763 to your computer and use it in GitHub Desktop.
Batching up database changes into a single save
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
// Source: Stanford CS193P November 16, 2010 Lecture 16 | |
// Use case: lots of Core Data changes. You want them to save once they settle down. | |
- (void)delayedSave:(NSManagedObjectContext *)ctxt | |
{ | |
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doSave:) object:ctxt]; | |
[self performSelector:@selector(doSave:) withObject:ctxt afterDelay:1.0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment