Skip to content

Instantly share code, notes, and snippets.

@jwhitehorn
Created January 1, 2018 23:00
Show Gist options
  • Save jwhitehorn/b4909302c23d19ada1f3954629924818 to your computer and use it in GitHub Desktop.
Save jwhitehorn/b4909302c23d19ada1f3954629924818 to your computer and use it in GitHub Desktop.
- (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