Created
January 1, 2018 23:00
-
-
Save jwhitehorn/b4909302c23d19ada1f3954629924818 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) applyOutstandingUpdates { | |
| __weak id this = self; | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| if(![this isUpdatePending]){ | |
| return; //no update pending | |
| } | |
| NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *documentsDirectoryPath = [documentPaths objectAtIndex:0]; | |
| NSString *updatePath = [documentsDirectoryPath stringByAppendingPathComponent:@"updated.db"]; | |
| NSString *dbPath = [documentsDirectoryPath stringByAppendingPathComponent:@"database.db"]; | |
| NSFileManager *fileManager = [NSFileManager defaultManager]; | |
| NSError *err; | |
| [fileManager moveItemAtPath:updatePath toPath:dbPath error:&err]; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment