简体   繁体   English

使用findObjectsInBackgroundWithTarget时调用中的参数#1缺少参数

[英]Missing argument for parameter #1 in call when using findObjectsInBackgroundWithTarget

I am trying to get an array of PFObjects, [PFObject] , from Parse and seeing the issue below. 我正在尝试从Parse获取PFObjects数组[PFObject] ,并看到下面的问题。 What am I missing? 我想念什么?

Error is Missing argument for parameter #1 in call 错误是调用中参数#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()

        }


    }

}

Error: 错误: 在此处输入图片说明

It seems that you want to handle the response with a block but you decided to use findObjectsInBackgroundWithTarget . 似乎您想使用一个块来处理响应,但是您决定使用findObjectsInBackgroundWithTarget You should go with findObjectsInBackgroundWithBlock: . 您应该使用findObjectsInBackgroundWithBlock:。 So you should be having something like this: 所以你应该有这样的事情:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM