【发布时间】:2016-04-14 01:32:04
【问题描述】:
我是第一次使用云代码并尝试调用以下函数:
let friendRequest: PFObject = self.friendRequestsToCurrentUser[sender.tag] as PFObject
let fromUser: PFUser = friendRequest[FriendRequestKeyFrom] as PFUser
//call the cloud code function that adds the current user to the user who sent the request and pass in the friendRequest id as a parameter
PFCloud.callFunctionInBackground("addFriendToFriendsRelation", withParameters: ["friendRequest": friendRequest.objectId]) { (object:AnyObject!, error: NSError!) -> Void in
let friendsRelation: PFRelation = PFUser.currentUser()!.relationForKey("friends")
friendsRelation.addObject(fromUser)
self.currentUser.saveInBackgroundWithBlock({ (succeeded: Bool, error: NSError!) -> Void in
if succeeded {
} else {
}
})
}
}
实现该功能后,我需要添加“!”到参数中的 objectId 以展开它。 但是,这样做会给我留下错误:
无法将 '(AnyObject!, NSError!) -> Void' 类型的值转换为 预期参数类型“PFIdResultsBlock?”
我必须改变什么才能调用这个函数?
【问题讨论】:
标签: ios swift parse-platform parse-cloud-code