For below code, getting Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)
error and not able to run the parse query in background. Any thoughts?
var data = Query.findObjectsInBackgroundWithBlock(
{(object:AnyObject!, error:NSError!) -> Void in
})
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
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With