如何解决错误“无法使用类型为((AnyObject !, NSError!)-> Void)的参数列表调用'findObjectInBackgroundWithBlock' [英] How to fix error "Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)

查看:61
本文介绍了如何解决错误“无法使用类型为((AnyObject !, NSError!)-> Void)的参数列表调用'findObjectInBackgroundWithBlock'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下代码,出现Can't invoke 'findObjectInBackgroundWithBlock' with an argument list of type ((AnyObject!, NSError!) -> Void)错误,并且无法在后台运行解析查询.有什么想法吗?

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

})

推荐答案

如果您使用的是Swift 1.2(Xcode 6.3),则需要通过以下方式调用该函数:

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

})

如果您使用的是Swift 1.1(Xcode 6.1、6.2),则需要通过以下方式调用该函数:

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

})

这是不同的,因为快速更新1.2(使用可选选项进行了更改).

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

这篇关于如何解决错误“无法使用类型为((AnyObject !, NSError!)-> Void)的参数列表调用'findObjectInBackgroundWithBlock'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆