Palash Sharma
Palash Sharma

Reputation: 682

Parse query results in error

I've a parse.com query written in swift but it doesn't let the whole project run but without it everything is fine. The error I get is Command failed due to signal: Segmentation fault: 11. The query is below:

Code

        let ObjectIDQuery = PFQuery(className: "Restaurants")
        ObjectIDQuery.whereKey("City", equalTo: CityName)
        ObjectIDQuery.orderByDescending("RN")
        ObjectIDQuery.findObjectsInBackgroundWithBlock({
            (objectsArray: [AnyObject]?, error: NSError?) -> Void in

            var ObjectIDS = objectsArray as! [PFObject]
            for i in 0..<ObjectIDS.count{
                self.name.append(ObjectIDS[i].valueForKey("Name") as! String)
                self.rating.append(ObjectIDS[i].valueForKey("Rating") as! String)
                self.phone.append(ObjectIDS[i].valueForKey("Number") as! String)
                self.url.append(ObjectIDS[i].valueForKey("Website") as! String)
                self.anp.append(ObjectIDS[i].valueForKey("ANP") as! String)
                self.image.append(ObjectIDS[i].valueForKey("Image") as! String)

                self.tableView.reloadData()

            }
        })

Please help

Edit: I have found out the problem lies in ObjectIDQuery.findObjectsInBackgroundWithBlock({

Upvotes: 0

Views: 319

Answers (1)

Santhosh
Santhosh

Reputation: 691

If you are using the latest Parse SDK and Swift 2, the method signature for PFQuery.findObjectsInBackgroundWithBlock has changed. Refer: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/280

Replace (objectsArray: [AnyObject]?, error: NSError?) -> Void in with (objectsArray: [PFObject]?, error: NSError?) -> Void in

Upvotes: 2

Related Questions