I am having trouble synchronizing my local data with Parse data when using ´enableLocalDataStore´. If I don't use local storage everything is fine, but I would like to minimize calls to Parse server. I understand that if I use ´saveEventually´ for newly created objects these will persist (pinned) locally and be synced with Parse when internet connection is available. This also works fine. My problem is that I don´t know the best method to update the local 'dataStore' with Parse 'dataStore' except to call a method that fetches changes remotely and updates locally. Currently, use the following:
-(void) fetchAllFavorites{
PFQuery *query = [PFQuery queryWithClassName:@"UserStats"];
[query fromLocalDatastore];
[[query findObjectsInBackground] continueWithBlock:^id(BFTask *task) {
if (task.error) {
}
else
{
[PFObject pinAll:task.result];
}
return task.result;
}];
}
This approach does not account for changes that may have occurred in Parse 'dataStore'. I could just unpin all local objects and fetch whatever is in Parse by calling a method directly. However, I would think there would be a better approach that seamlessly syncs local changes with changes in the Parse 'dataStore'? Is that not the idea behind allowing the use of 'localDataStore' in the first place ? Currently, I can only see that this works one way: you store data locally and then update the Parse 'dataStore' manually, but you don't really sync between these. At least this is the idea I get from some of the examples and I wonder if anyone has a good approach to how to: how to enable 'localDataStore' that is continuously synchronized with Parse 'dataStore'? Any suggestions and examples would be very helpful. I am programming in Cocoa but Java examples would also be great. Thanks, T.