I have 2 files.
- myTableViewController.swift
- myTableCell.swift
Is it possible to get indexPath.row in myTabelCell.swift function?
Here is myTableCell.swift
import UIKit import Parse import ActiveLabel class myTableCell : UITableViewCell { //Button @IBOutlet weak var commentBtn: UIButton! @IBOutlet weak var likeBtn: UIButton! @IBOutlet weak var moreBtn: UIButton! override func awakeFromNib() { super.awakeFromNib() } @IBAction func likeBtnTapped(_ sender: AnyObject) { //declare title of button let title = sender.title(for: UIControlState()) //I want get indexPath.row in here! }
Here is myTableViewController.swift
class myTableViewController: UITableViewController { //Default func override func viewDidLoad() { super.viewDidLoad() //automatic row height tableView.estimatedRowHeight = 450 tableView.rowHeight = UITableViewAutomaticDimension } // cell config override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { //define cell let cell = tableView.dequeueReusableCell(withIdentifier: "myTableCell", for: indexPath) as! myTableCell }
As you can see ... I'm trying to get indexPath.row in myTableCell, liktBtnTapped.
Could you tell me how can I access or get IndexPath.row?
uitableview swift nsindexpath
Shawn baek
source share