Reputation: 4911
Suppose that there are two iDevices: device1
and device2
. Both devices have pinned some object foobar
retrieved from the Parse backend.
device1
performs a -deleteEventually
on foobar
. This causes the object to also be automatically unpinned. This deletion is propagated to the backend, and the backend now has removed foobar.
device2
performs a query that would normally fetch foobar
; except, it's missing.
What happens to foobar
on device2
's local datastore?
Upvotes: 3
Views: 4018
Reputation: 1241
Here is solution for this type of issue that I'm using in my app:
And code sample:
- (BFTask *)find:(PFQuery *)query {
return [[query findObjectsInBackground] continueWithSuccessBlock:^id(BFTask *task) {
BFTask *(^pin)(void) = ^ {
return [[PFObject pinAllInBackground:task.result] continueWithExecutor:[BFExecutor mainThreadExecutor]
withSuccessBlock:^id(BFTask *task) {
return task.result;
}];
};
[query fromLocalDatastore];
return [[query findObjectsInBackground] continueWithBlock:^id(BFTask *task) {
if (!task.error && [task.result count]) {
return [[PFObject unpinAllInBackground:task.result] continueWithBlock:^id(BFTask *task) {
return pin();
}];
} else {
return pin();
}
}];
}];
}
Upvotes: 1
Reputation: 1388
As local datastore is...local, then the object will be keeped in the second device until it receives an update about the objects, and pinned those again (after unpin obviously). No changes will be made in the second one if you are not requesting new objects from the Backend.
Upvotes: 3