How to fix error “Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)

2 Solutions Collect From Internet About “How to fix error “Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)”

If you are using swift 1.2 (Xcode 6.3) you need to call the function by:

var data = Query.findObjectsInBackgroundWithBlock({(objects:[AnyObject]?, error:NSError?) -> Void in

})

And if you are using swift 1.1 (Xcode 6.1, 6.2) you need to call the function by:

var data = Query.findObjectsInBackgroundWithBlock({(objects:[AnyObject]?, error:NSError!) -> Void in

})

This is different because of the swift update 1.2 which has changes with using optionals.

You should change object parameters type to array of AnyObject, and both parameters types to optional. So parameters should be (object: [AnyObject]?, error: NSError?).

Like below:

var data = Query.findObjectsInBackgroundWithBlock({(object: [AnyObject]?, error: NSError?) -> Void in

})