I am trying to use local-datastore with iOS.
Say I have two or more devices.
I use saveEventually to save data locally (and on cloud). When working only on one device it works fine.
When I start working with more than one device, to sync I use:
PFQuery *query = [UserPreference query];
[query whereKey:@"userId" equalTo: [PFUser currentUser].objectId];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
if(!error){
[UserPreference pinAllInBackground:objects block:^(BOOL succeeded, NSError *error) {<---- objects here are fine
if(succeeded){
[query fromLocalDatastore];
NSLog(@"Local %@", [(UserPreference*)[[query findObjects] objectAtIndex:0] filterContext ]); <--- however here the old value is retrieved
}
}];
}
}];
So I get proper objects from the cloud, then i PinAll but when i retrieve from localDataStore Old values are retrieved?
Could anyone be kind to explain : 1. if this is feasible at all i.e to sync between two devices using local data store 2. what I am doing wrong?
PS: I notice that serverData in objects contains the correct info but does not update the object