what happens in iOS when nscoding writeToFile is saving and user closes the app?
NSData *d = [NSKeyedArchiver archivedDataWithRootObject:self];
[d writeToFile:FILE_PATH atomically:YES];
For example suppose there is 100 MB of user data to save - it will probably take a while (NSData writeToFile is really slow) - so if the user closes the app, will the write process just not finish and you wouldn't have your data synced?
If so, is there a way to prevent the user from closing the app until you are done saving?
Atomically, to put simply, makes ensures either ALL of the file is written or NONE of it.
Nonatomically allows some of the file to be written and cut off.
If there is some reason why the app is terminated before the whole file is written and you're using atomically, the file will NOT be written to storage. The process will be killed.
If the file is that large, I'd recommend starting up some sort of loading screen that tells the user not to close the app, and after it's completion hiding that loading screen to let them know that it's alright to close the app.