ios - 使用 findObjectsInBackgroundWithTarget 时,调用中参数 #1 缺少实参

标签 ios xcode swift xcode6.3

我正在尝试从 Parse 获取 PFObjects 数组 [PFObject] 并看到下面的问题。我错过了什么?

错误是调用中参数 #1 缺少参数

func loadData() {
    rooms = [PFObject]()
    users = [PFUser] ()

    self.tableView.reloadData()

    let pred = NSPredicate(format: "user1 = %@ OR user2 = %@", PFUser.currentUser()!, PFUser.currentUser()!)

    let roomQuery = PFQuery(className: "Rooms", predicate: pred)

    //gives us all the information - includeKey all columns for the user class itself
    roomQuery.includeKey("user1")
    roomQuery.includeKey("user2")

    roomQuery.findObjectsInBackgroundWithTarget{ (results: [AnyObject]!, error: NSError!) -> Void in

        if error == nil {
            self.rooms = results as [PFObject]

            for room in self.rooms {
                let user1 = room.objectForKey("user1") as PFUser
                let user2 = room.objectForKey("user2") as PFUser

                if user1.objectId != PFUser.currentUser() {
                    self.users.append(user1)
                }

                if user2.objectId != PFUser.currentUser() {
                    self.users.append(user2)
                }
            }
         self.tableView.reloadData()

        }


    }

}

错误: enter image description here

最佳答案

您似乎想用 block 处理响应,但您决定使用 findObjectsInBackgroundWithTarget。你应该选择 findObjectsInBackgroundWithBlock: 。所以你应该有这样的东西:

roomQuery.findObjectsInBackgroundWithBlock {(objects: [AnyObject]?, error: NSError?) -> Void in

关于ios - 使用 findObjectsInBackgroundWithTarget 时,调用中参数 #1 缺少实参,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29875173/

相关文章:

ios - 何时在 iOS 应用程序中使用 sqlite3_close

ios - 我从哪里获得 iPhone SDK

ios - UIView动画滑入

ios - 在 SwiftUI 中切换 View 后 Firebase 图像为空

ios - UIScrollView 不在 Swift 中滚动

ios - UISearchController - 不能很好地使用 subview Controller

iphone - 为什么 Xcode 会在钥匙串(keychain)中自动安装(重复和过期的)证书?

iOS swift : How to hide and reveal a button in UIViewController

ios - 如何在 InfoWindow 中包含一个按钮

ios - 使用 AlamofireImage 调整下载图像的大小