I am working with a comment and reply system for my iOS application. I had an issue with showing and hiding a button.

I created two XIB cells for my tableView one as a 'commentCell' and other is 'replyCell'. In comment cell I have a button (Reply) so when user clicks on "Reply" it should insert a cell at indexPath.row+1, in 'replyCell' I have a textview and two buttons (Submit) and (Cancel), so when user enter some text in textview and clicks on "Submit" it should store the reply text and textView shouldn't be able to edit after user clicks on "Submit" and if the user clicks on "Cancel" it should remove the 'replyCell' and delete row at indexPath.row

I am able to achieve all the above functionality..

Now my issue is: 

When the user clicks "Reply" button in 'commentCell', it should hide the "Reply" Button and I am able to do it by setting (replyBtn.isHidden = true) in the "Reply" button action. But, when user clicks on "Cancel" button in the 'replyCell' the "Reply" button in the 'commentCell' should show again and I don't get any idea on how to show the "Reply" button in "commentCell" by setting (replyBtn.isHidden = false) in "Cancel" button action.

The issue is, I can't access the replyBtn property in 'replyCell' as it is the property of "commentCell".

How to do it???

I hope you understand what I am trying to convey...

These are my protocols and tableView delegate methods in UICommentTableViewController:

```
protocol UICommentReply {

    func replyToCommentAtIndexPath(cell: UICommentTableViewCell)
}

protocol UICancelReply {

    func cancelReplytoComment(cell: UICommentReplyTableViewCell)
}

class UICommentTableViewController: UITableViewController,UICommentReply, UICancelReply {

   override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return tableContent.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell  {

        let row = indexPath.row
        let post = self.tableContent[row]
        switch post.type {
        case .Comment:
            let comment = post as! Comment
            let commentCell = tableView.dequeueReusableCell(withIdentifier: "commentCell", for: indexPath as IndexPath) as! UICommentTableViewCell
            commentCell.delegate = self
            commentCell.level = comment.level
            return commentCell
        case .Reply:

            let replyCell = tableView.dequeueReusableCell(withIdentifier: "replyCell", for: indexPath as IndexPath) as! UICommentReplyTableViewCell
            replyCell.delegate = self

            return replyCell
        default:
            return UITableViewCell()
        }
    }

   func replyToCommentAtIndexPath(cell: UICommentTableViewCell) {

        print(#function)
        if let path = tableView.indexPath(for: cell) {
            let indexPath = NSIndexPath(row: path.row + 1, section: path.section)
            self.tableContent.insert(Reply(), at: indexPath.row)
            self.tableView.insertRows(at: [indexPath as IndexPath], with: UITableViewRowAnimation.fade)

    }

    }

    func cancelReplytoComment(cell: UICommentReplyTableViewCell) {

        print(#function)
        if let path = tableView.indexPath(for: cell) {
        let indexPath = NSIndexPath(row: path.row, section: path.section)
            if self.tableContent[indexPath.row].type == .Reply {
                self.tableContent.remove(at: indexPath.row)
                self.tableView.deleteRows(at: [indexPath as IndexPath], with: UITableViewRowAnimation.fade)

            }
        }
    }

}

```

in UICommentTableViewCell:

```
@IBDesignable class UICommentTableViewCell: UITableViewCell {
 @IBOutlet weak var controlReplyButton: UIButton!

    var delegate: UICommentReply?

    override func awakeFromNib() {

        super.awakeFromNib()
        self.selectionStyle = UITableViewCellSelectionStyle.none

        controlReplyButton.setTitle("Reply", for: .normal)

        self.setup()
    }

    func setup() {

        self.controlReplyButton.addTarget(self, action: #selector(handleReplyButton(sender:event:)), for: UIControlEvents.touchUpInside)
    }

    func handleReplyButton(sender: UIButton, event: UIEvent) {

        controlReplyButton.isHidden = true

        self.delegate?.replyToCommentAtIndexPath(cell: self)
    }
}

```

in UICommentReplyTableViewCell:

```
class UICommentReplyTableViewCell: UITableViewCell {

    @IBOutlet weak var cancelReply: UIButton!

    @IBOutlet weak var postReplyBtn: UIButton!

    @IBOutlet weak var replyTextView: UITextView!

    var delegate: UICancelReply?

    override func awakeFromNib() {

        super.awakeFromNib()
        self.selectionStyle = UITableViewCellSelectionStyle.none

        self.setup()
    }

    func setup() {

        self.cancelReply.addTarget(self, action: #selector(cancelReplyButton(sender:event:)), for: UIControlEvents.touchUpInside)
 }

    func cancelReplyButton(sender: UIButton, event: UIEvent) {

        self.delegate?.cancelReplytoComment(cell: self)

    }
}

```

This is the code I had so far, and help me with it.

[Comment Screen](https://i.stack.imgur.com/HjPNV.png)

[Comment Reply Screen](https://i.stack.imgur.com/9ZMXR.png)