title: tableview button creation dynamically in cell issue in swift
body: <p>I am trying to implement  dynamic button  on tableview cell .i am able to add the button but as per the requirement on last cell i don't want to add button  but its getting added there also as below mention screen capture </p>
  
  <p><img src="https://i.stack.imgur.com/VHXg6.png" alt="enter image description here"></p>
  
  <p>This is the requirement
  my cellForRowAt indexPath code is below.</p>
  
  <pre><code> func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
      if let _ = cell {
          print("cell is available")
      } else {
          cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
      }
      cell?.textLabel?.textAlignment = .left
      cell?.textLabel?.text = list[indexPath.row]
      let btn = UIButton(type: UIButtonType.custom) as UIButton
  
      if cell?.textLabel?.text == "➕ Add Room" || list[indexPath.row] == "➕ Add Room"{
          btn.isHidden = true
          cell?.textLabel?.textAlignment = .center
      }else{
          btn.frame = CGRect(x: 146, y: 0, width: 20, height: (cell?.frame.height)!)
          btn.addTarget(self, action: #selector(buttonPressed(sender: )), for: .touchUpInside)
          btn.tag = indexPath.row
          btn.setImage(UIImage(named: "delete.png"), for: .normal)
          cellx = list[btn.tag]
          cell?.contentView.addSubview(btn)
      }
      return cell!
  }
  </code></pre>
  
  <p>and the result after this show below screen capture</p>
  
  <p><img src="https://i.stack.imgur.com/ZZcad.png" alt="enter image description here"></p>
  
  <p>i don't want to display the delete button in +Add Room row which is present in last row of table. 
  Please suggest me how to get the out as mention in the requirement . i made a condition for the text ("Add Room Text") to shown in centre and successfully displaying in center.
  Thanks in advance please help me to solve this issue</p>
  
  <p><strong>2nd issue</strong></p>
  
  <p>in this given list if i select "COPENHAGEN " and try to delete this , its deleting the upper content means BARCELONA file gets deleted.  i am not delete same seleted content from list .</p>