本文介绍了findObjectsInBackgroundWithBlock块签名不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此代码获取一堆行
I'm trying to fetch a bunch of rows with this code
var query = PFQuery(className:"Test")
query.findObjectsInBackgroundWithBlock {
(objects: NSArray?, error: NSError?) in
// do something
}
但是它无法编译,我收到以下错误:
But it doesn't compile, I get the following error:
在文档我找到了:
似乎与我非常相似.我在做什么错了?
Which seems to be pretty similar to me. What am I doing wrong?
推荐答案
在另一篇帖子中找到了正确的语法.参数列表或包装/展开对象都没有问题;相反,必须将闭包作为参数传递给findObjectsInBackgroundWithBlock
.像这样写时可以工作:
Found the correct syntax in another post. Nothing wrong with the arguments list or wrapping/unwrapping the objects; instead, the closure had to be passed as an argument to findObjectsInBackgroundWithBlock
. It works when written like this:
query.findObjectsInBackgroundWithBlock( { (NSArray results, NSError error) in
// do something
})
这篇关于findObjectsInBackgroundWithBlock块签名不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!