简体   繁体   中英

Can't retrieve local data (pinned objects) from Parse Local Datastore

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:

  1. Pin some objects with btnAddTouched: ;
  2. Close the app (stop debbuging);
  3. Open the app again (build again);
  4. 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.

Parse iOS SDK版本1.6.1修复了此错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM