Is saving game state still important on modern iOS devices?

What is the probability that a game app with a game in progress will be shut down due to memory pressure on a modern iOS device?

Remember, even though modern iOS devices have a lot more memory than previous models did, it's still a finite amount. And most users do not immediately quit every app manually the instant they leave it—apps just kind of pile up and get shut down and reloaded all the time. So, in my opinion, it's always going to be a wise choice to save game state. (And, it's better to have such a mechanism and not need it than to have users getting frustrated that their games are not being saved!)

Saving game state is a potential source of bugs and security issues (i.e., cheating) though.

Yes, with any code there is the possibility of introducing bugs, but I would think that an app that didn't save any state might be viewed as buggier because iOS users expect their data to be saved.


Now about the cheating thing, remember that users have no direct access to the iOS file system, and apps cannot read and write across containers, so it's not a likely scenario. Besides, I don't see cheating on a game as a "security issue"… (unless, of course, your game requires in-app-purchases or something like that in order to succeed, but for those you have other secure mechanisms)

Actually, "....users have no direct access to the iOS file system," may not be correct. I believe you can access NSUserDefaults through an iTunes backup from your desktop. If this is an issue then save your stuff this way:


    NSMutableDictionary *parametersDeepCopy=[NSKeyedUnarchiver unarchiveObjectWithData:
                                             [NSKeyedArchiver archivedDataWithRootObject:myDictionary]];
    NSError *error=nil;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *dataPath = [rootPath stringByAppendingPathComponent:@"datafile"]:
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:parametersDeepCopy];
    [data writeToFile:dataPath atomically:YES];
   

//and recover it this way:


    NSString *dataPath;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
    dataPath = [rootPath stringByAppendingPathComponent:@"datafile"];
    if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
        NSData *data = [[NSFileManager defaultManager] contentsAtPath:dataPath];
        NSMutableDictionary *tempDictionary =[NSKeyedUnarchiver unarchiveObjectWithData:data];
        [myDictionary addEntriesFromDictionary:tempDictionary];
    }
    
  



and if you are really concerned, also save a signed SHA1 hash of 'data' to test the recovered 'data'

We can tell you about the negative reviews you're going to get when people end up losing their game progress because they had to:

- answer the phone

- check their e-mail

- check the weather

or do any number of other things that they thought would just be a brief interruption.


If you're making a big fancy game that consumes a lot of memory, then when your app is the background it's going to be the top the list for apps to kill to free up memory when the e-mail app asks for more memory.

You're asking the wrong question. Failing to save game state is horrible user experience and

would likely result in your game either being reviewed very poorly or worse, rejected outright

by app review. It's your job, as a developer, to make sure the game either starts over or

continues where it left off, no matter how long the interval between runs may be. Failing that

is just sloppy.


Games especially, should monitor and respond to memory warnings.

Is saving game state still important on modern iOS devices?
 
 
Q