【发布时间】:2014-09-06 08:14:45
【问题描述】:
我想在 tableViewCell 中实现 IBAction。 tableView 显示用户列表,对于每个用户,我都有一个关注按钮。
follow方法需要指定要关注的用户是cell的用户。
我该怎么做?
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)
}
}
}
【问题讨论】:
标签: uitableview swift parse-platform ibaction