How to fix the "Unable to call" findObjectInBackgroundWithBlock "error using an argument list of type ((AnyObject !, NSError!) & # 8594; Void)

The following is an error code Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)and the analysis request cannot be completed in the background. Any thoughts?

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

})
+4
source share
2 answers

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

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

})

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

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

})

This is different from Quick Update 1.2, which has changes using options.

+4
source

object AnyObject, - . (object: [AnyObject]?, error: NSError?).

:

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

})
+3

All Articles