Reputation: 183
I have this code working on swift 2, it's serve to getting row of UITableView cell on button press:
@IBAction func commentsButtonAction(sender: AnyObject) {
let btnPos: CGPoint = sender.convert(point:CGPoint.zero, toView: self.tableView)
let indexPath: NSIndexPath = self.tableView.indexPathForRow(at: btnPos)! as NSIndexPath
passaValor = indexPath.row
performSegue(withIdentifier: "searchToComments", sender: self)
}
In swift 3 I receive this error
Cannot invoke 'convert' with an argument list of type '(point: CGPoint, toView: UITableView!)'
Any ideas? Thanks.
Upvotes: 1
Views: 1702
Reputation: 2777
Try this
myButton.addTarget(self, action: "connected:", forControlEvents: .TouchUpInside))
And you need to this
myButton.tag = indexPath.row
func connected(sender: UIButton){
let buttonTag = sender.tag
}
Hope this helps.
Upvotes: 0
Reputation: 9044
The signature of the method has been changed under Swift 3. It is now:
func convert(CGPoint, to: UIView?)
Therefore you would call it as:
sender.convert(CGPoint.zero, to: self.tableView)
Upvotes: 1