Ios 无法调用findObjectsInBackgroundWithBlock swift错误
因此,在将所有用户从parse发送到我的应用程序时,我遇到了这个错误: 无法使用参数列表调用“findObjectsInBackgroundWithBlock” 类型为“([AnyObject]!,n错误!)->Void” 正在尝试运行此代码:Ios 无法调用findObjectsInBackgroundWithBlock swift错误,ios,swift,parse-platform,Ios,Swift,Parse Platform,因此,在将所有用户从parse发送到我的应用程序时,我遇到了这个错误: 无法使用参数列表调用“findObjectsInBackgroundWithBlock” 类型为“([AnyObject]!,n错误!)->Void” 正在尝试运行此代码: var userQuery = PFUser.query() userQuery.findObjectsInBackgroundWithBlock({(objects: [AnyObject]!, error: NSError!) -&g
var userQuery = PFUser.query()
userQuery.findObjectsInBackgroundWithBlock({(objects: [AnyObject]!, error: NSError!) -> Void in
self.users.removeAll(keepCapacity: true)
for object in objects {
var user:PFUser = object as PFUser
self.users.append(user.username)
}
self.tableView.reloadData()
})
我使用的是xcode 6.3,有什么解决方案吗?我尝试在[AnyObject]之后添加“?”而不是“!”,但似乎没有任何帮助。这些代码行工作正常:
var losingUserQuery = PFUser.query()
losingUserQuery.findObjectsInBackgroundWithBlock {
(results: [AnyObject]!, error: NSError!) -> Void in
if error == nil && results != nil {
self.arrayMyPostsFromParse.removeAll(keepCapacity: false)
for usr in results{
var user:PFUser = usr as PFUser
self.arrayMyPostsFromParse.append(user.username! as NSString
}
self.tblUsers.reloadData()
} else {
println(error)
}
}
实际上,我是这样编码的
var data: Void? = query?.findObjectsInBackgroundWithBlock({(objects:[AnyObject]?, error:NSError?) -> Void in
self.users.removeAll(keepCapacity: true)
for object: AnyObject in objects! {
var user:PFUser = object as! PFUser
self.users.append(user.username!)
}
self.tableView.reloadData()
})
self.users.removeAll(keepCapacity:false)。如果不保持容量,会发生什么?。也可以这样做self.users=query.findObjects()您编写的代码是正确的..这些似乎都不起作用。。代码应该是正确的,不知道为什么它会向我抛出这个错误。只是在下面测试代码就可以了。如果这不起作用,那么从首字母开始:检查applicationID和ClientID,重要的是用户表必须包含记录:请确保此数组ArrayPostsFromParse的类型为StringIt仍然给我那个该死的错误,检查ClientID,所有内容似乎都是正确的,不知道可能有什么错误。请重命名for循环中的“object”。它可能会给您带来错误,因为它是iOS中的预定义词