How to fix "getDataInBackgroundWithBlock" error in swift

58 views Asked by At

Can't I use "getDataInBackgroundWithBlock" for PFQuery?

I tried to get picture from the server. But the code doesn't work at all. Xcode usually provides autocomplete code function. But "getDataInBackgroundWithBlock" wasn't worked. How can I fix this?

Please check the below code.

let information = PFQuery(className: "messages")
        information.findObjectsInBackground { (objects, error) in
            if error == nil {
                for object in objects!{
                    self.messageLbl.text = object["message"] as? String
                    self.receiverLbl.text = object["receiver"] as? String
                    self.senderLbl.text = object["sender"] as? String

                    object["picture"].getDataInBackgroundWithBlock({ (data, error) in
                        if error == nil {
                            if data != nil{
                                self.picture.image = UIImage(data : data!)
                            }else{
                                print(error)
                            }
                        }

                    })
                }
            }else{
                print(error)
            }
        }

the error message is "Value of type 'Any?' has no member 'getDataInBackgroundWithBlock'"

0

There are 0 answers