-1
我想在tableViewCell中实现一个IBAction。 tableView不能显示用户列表,对于每个用户,我有一个关注按钮。Swift /解析:IBAction在tableViewCell中做出pfrelation
以下方法需要指定用户跟随女巫是单元格的用户。
我怎么能这样做?
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: AddFirendsTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)as AddFirendsTableViewCell
let users:PFObject = self.userList.objectAtIndex(indexPath.row) as PFObject
return cell
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let users:PFObject = self.userList.objectAtIndex(indexPath.row) as PFObject
}
@IBAction func followUnfollow(sender: AnyObject) {
//what should i put here ?
}
func follow (user :PFUser) {
var relation : PFRelation = PFUser.currentUser().relationForKey("KfriendsRelation")
relation.addObject(user)
PFUser.currentUser().saveInBackgroundWithBlock { (succeed:Bool, error: NSError!) -> Void in
if error != nil {
println(error)
}
}
}