I am trying to use local-datastore with iOS.
Say I have two or more devices.
I use saveEventually to save data locally (and in the cloud). When working on only one device, it works great.
When I start working with several devices, for synchronization 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 the proper objects from the cloud, then I PinAll, but when I retrieve from localDataStore, are the old values retrieved?
Could someone please be kind enough to explain: 1. if at all possible, then for synchronization between two devices using local data storage 2. What am I doing wrong?
PS: I notice that serverData in the objects contains the correct information, but does not update the object