0
votes

just switched over to Swift2, and am getting this compiler error. Can someone tell me what's wrong with this code?

nameSpotQuery.findObjectsInBackgroundWithBlock{(results: [AnyObject]?, error: NSError?) -> Void in

        if error != nil {
            print(error)

        }

        if let objects = results as? [PFObject]{
            self.searchResults.removeAll(keepCapacity: false)

            for object in objects {
                let name = object.objectForKey("Name") as! String
                self.searchResults.append(name)
            }

            dispatch_async(dispatch_get_main_queue()){
                self.collectionView.reloadData()
                self.searchBars.resignFirstResponder()
            }
        }
    }
1
Try removing dispatch_async(dispatch_get_main_queue()){ - egor.zhdan
Removed dispatch didn't work :( - chuninator
collectionTestViewController.swift:68:47 - line:94:9] it's on a line that just has a bracket... - chuninator
since the update today, I get the same error when calling the function findObjectsInBackgroundWithBlock, you will probably find, that even if you comment out everything inside, it won't compile - Daniel

1 Answers

0
votes

Change [AnyObject]? for [PFObject]? in the block.

This was updated on ParseSDK 1.8.3, download the latest version if you haven't.

Hope I could help.