【发布时间】:2015-05-20 01:33:31
【问题描述】:
我想运行一个查询来确定 Swift 中 tableView 中的行数。当我使用查询 results.count 方法时,出现以下错误:
Int? is not convertible to 'Void'
这是引发错误的函数:
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let user = self.user {
var currentUserQuery = PFQuery(className: "Game")
currentUserQuery.whereKey("user1", equalTo: PFUser.currentUser()!)
currentUserQuery.whereKey("isActive", equalTo: true)
var currentUserQuery2 = PFQuery(className: "Game")
currentUserQuery2.whereKey("user2", equalTo: PFUser.currentUser()!)
currentUserQuery2.whereKey("isActive", equalTo: true)
var query = PFQuery.orQueryWithSubqueries([currentUserQuery, currentUserQuery2])
query.findObjectsInBackgroundWithBlock{
(results: [AnyObject]?, error: NSError?) -> Void in
if error != nil {
println(error)
}
if error == nil{
//continue an active game that already exists with the user
if results != nil{
return results!.count as? Int
如果我将(results: [AnyObject]?, error: NSError?) -> Void 更改为(results: [AnyObject]?, error: NSError?) -> Int,我会得到一个不同的错误:
Cannot invoke 'findObjectsInBackgroundWithBlock' with an argument list of type '(([AnyObject]?, NSError?) -> Int)'
我该怎么办?
谢谢!
【问题讨论】:
-
你不能使用同步方法返回它
-
感谢您的回复!有没有推荐的解决方法?
-
填充您的表格视图或在获取您的信息后重新加载它。
标签: uitableview swift parse-platform