Parse.com querying User class (swift)

六月ゝ 毕业季﹏ 提交于 2019-11-28 12:21:16

User isn't the appropriate name for the User table. You need to use the following:

var query : PFQuery = PFQuery(className: "_User")

A more appropriate method is:

var query : PFQuery = PFUser.query()

You cannot query users like that. Instead you need:

var findUsers:PFQuery = PFUser.query();
findUsers.whereKey("username",  equalTo: searchText.text)

See Parse documentation:

https://parse.com/docs/ios_guide#users-querying/iOS

Daewizal Forshizal

I've been stuck on this part of code too. I was able to query users and their data with this code:

    var usernames = [String]()
    var userImages = [Data]()

    var query : PFQuery = PFUser.query()!
                    // Interested in locations near user.
                    query.whereKey("location", nearGeoPoint: geopoint!)
                    // Limit what could be a lot of points.
                    query.limit = 10
                    do {
                        let queryObjects = try query.findObjects()
                        for object in queryObjects {
                            self.usernames.append(object["username"] as! String)
                            self.userImages.append(object["image"] as! Data)
                        }
                    } catch {
                        print("Error")
                    }

try this ...

 var ObjectIDQuery = PFQuery (className: "User")
    ObjectIDQuery.findObjectsInBackgroundWithBlock({
        (objectsArray : [AnyObject]?, error: NSError?) -> Void in



        var objectIDs = objectsArray as! [PFObject]

        NSLog("\(objectIDs)")

        for i in 0...objectIDs.count-1{
            self.NameArray.append(objectIDs[i].valueForKey("username")as!  String)


            self.iDArry.append(objectIDs[i].valueForKey("objectId") as!  String)

            self.tableView.reloadData()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!