所以在让所有用户从解析到我的应用程序时遇到了这个错误:
无法使用参数列表调用"findObjectsInBackgroundWithBlock" 类型为'(([AnyObject]!, NSError!) -> Void)'
尝试运行此代码:
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 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()
})
这些代码行工作正常:
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)
}
}