简体   繁体   中英

Can't get pin object from local parse database

I am using parse for my iOS app and it works fine.

I wanted to implement offline feature so I am using pinInBackground to save PFObject to local database. But I can't retrieve it.

For my special reason, I've generated unique UUID for every PFObject pin name and used it.

{

...

    NSString *uuid = [[NSUUID UUID] UUIDString];
    [CustomObject pinInBackgroundWithName:uuID];
...

}

It returns success but I can't retrieve it.

Following is the query code to get pin Object .

{

...

    PFQuery *query = [CustomObject query];
    [query fromLocalDatastore];
    [query fromPinWithName:uuID];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
     {
         if(!error)
             block(objects, nil);
         else
             block(nil, error);
     }];
...

}

But objects has 0 elements always.

Any help would be greatly appreciated.

Thanks

Update:

This is the Pin object saved in parse local database.

{"isDeletingEventually":0,"className":"_Pin","__complete":true,"__operations":[{"_name":"16F31F2C-6375-4107-A0B6-FDCBA9810847","__updatedAt":{"__type":"Date","iso":"2017-07-02T18:33:02.825Z"},"_objects":[{"__type":"OfflineObject","uuid":"FF3D069C-864F-4D87-9511-F2738A5F95F4"}],"__uuid":"71BAF309-58D4-4BCC-82D8-BB35C25F1632"}]}

The problem was the query for local database.

I've changed the query like this and it worked for me.

{

...
PFQuery *query = [[[CustomObject query] fromLocalDatastore]ignoreACLs];
[query fromLocalDatastore];
[query fromPinWithName:uuID];
...

}

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