First of all you need to enable the use of local datastore:
[Parse enableLocalDatastore];
Next, I always save a new PFObject to the local datastore using
PFObject *userStat;
[userStat saveEventually];
This will both pin your object to the local datastore and save it to cloud (eventually). If you want to reset all of your locally stored data with what you have in the cloud, you can; first unpin all your local objects and then fetch all the remote objects and pin them locally:
[PFObject unpinAllObjects];
PFQuery *query = [PFQuery queryWithClassName:@"UserStats"];
[query whereKey:@"parent" matchesQuery:query];
return [[query findObjectsInBackground] continueWithBlock:^id(BFTask *task) {
if (task.error){
return nil;
}
return [[PFObject pinAllInBackground:task.result] continueWithBlock:^id(BFTask *task) {
return task;
}];
}];
Local queries can be done using:
[query fromLocalDatastore];
Parse has good documentation of these methods here.