Whether they’re on a long flight, riding through a subway tunnel, or camping in a national park, sometimes it’s just not possible for users to get a network connection. But that doesn’t mean they should be without their favorite mobile apps. So how can you save that latest page number when reading offline? Or remember the latest achievement unlocked in a game?
To address this problem, we have added the ability to save objects offline.
// Create the object. PFObject *gameScore = [PFObject objectWithClassName:@"GameScore"]; [gameScore setObject:[NSNumber numberWithInt:1337] forKey:@"score"]; [gameScore setObject:@"Sean Plott" forKey:@"playerName"]; [gameScore setObject:[NSNumber numberWithBool:NO] forKey:@"cheatMode"]; // Save it as soon as is convenient. [gameScore saveEventually];
If the user doesn’t have a network connection, the object will be stored safely on the device until a new connection has been established. If the app is closed before the connection is back, Parse will try to save it again the next time the app is opened.
As always, let us know what you think.