简体   繁体   中英

PFUser objects not retrievable from local Local Datastore (iOS)

I managed to save and retrieve custom objects from the local datastore with the help of Parse. Unfortunately the same method doesn't work for PFUser objects. Do I have to do something different?

This is what I implemented:

PFQuery *query = [PFQuery queryWithClassName:@"PFUser"];


    [query fromLocalDatastore];


    [query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {


        DDLogDebug(@"objects: %@", objects);


    }];

I retrieved the objects from the server and did pinInBackground on them (the method didn't give me an error so I guess the objects are saved correctly in the database).

I came across the same problem. It comes from the declaration of your query. You should write:

PFQuery *query = [PFUser query];

instead of :

PFQuery *query = [PFQuery queryWithClassName:@"PFUser"];

In swift ,

the correct form is:

let localGuyQuery = PFUser.query()

And not:

let localGuyQuery = PFQuery(className: "User") 

Note that I only work in swift, I got inspiration for the objC version from this post

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