问题
I can't retrieve the local data (pinned objects) after re-open the app.
I have this code in my controller:
- (IBAction)btnAddTouched:(id)sender
{
PFObject *object = [PFObject objectWithClassName:@"Foobar"];
[object setValue:[[NSDate date] description] forKey:@"data"];
[object pinInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"Pinned OK");
}else{
NSLog(@"Erro: %@", error.localizedDescription);
}
}];
}
- (IBAction)btnLoadTouched:(id)sender
{
PFQuery *query = [PFQuery queryWithClassName:@"Foobar"];
[query fromLocalDatastore];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"%@", objects);
}else{
NSLog(@"Erro: %@", error.localizedDescription);
}
}];
}
Steps to reproduce:
- Pin some objects with
btnAddTouched:
; - Close the app (stop debbuging);
- Open the app again (build again);
- Try Load pinned data with
btnLoadTouched
;
It is retrieving me a object with localId: (null)
:
"<Foobar: 0x15d42770, objectId: new, localId: (null)> {\n data = \"2014-12-15 21:00:05 +0000\";\n}"
)
And after that the pinInBackgroundWithBlock:
won't work anymore. The blocks is never called then.
回答1:
The Parse iOS SDK release 1.6.1 fixed this bug.
来源:https://stackoverflow.com/questions/27493200/cant-retrieve-local-data-pinned-objects-from-parse-local-datastore