我正在try 运行一个操作,以便在表格视图单元格中按下一个按钮.下面的代码在我的表视图控制器类中.
在我的UITableViewCell类中的一个名为requestsCell的插座中,该按钮被描述为"是".
我正在使用Parse来保存数据,并希望在按下按钮时更新对象.我的ObjectID数组运行良好,单元格.对tag还将正确的数字打印到日志(log)中,但是,我无法将该数字输入到我的"已连接"函数中,以便正确运行查询.
我需要一种方法来获取信息.用于查找正确的objectId的单元格行.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as requestsCell
// Configure the cell...
cell.name.text = requested[indexPath.row]
imageFiles[indexPath.row].getDataInBackgroundWithBlock{
(imageData: NSData!, error: NSError!) -> Void in
if error == nil {
let image = UIImage(data: imageData)
cell.userImage.image = image
}else{
println("not working")
}
}
cell.yes.tag = indexPath.row
cell.yes.targetForAction("connected", withSender: self)
println(cell.yes.tag)
return cell
}
func connected(sender: UIButton!) {
var query = PFQuery(className:"Contacts")
query.getObjectInBackgroundWithId(objectIDs[sender.tag]) {
(gameScore: PFObject!, error: NSError!) -> Void in
if error != nil {
NSLog("%@", error)
} else {
gameScore["connected"] = "yes"
gameScore.save()
}
}
}