title: Swift: Inheritance of xib files
body: <p>I have two xib files which almost the same.</p>
  
  <p><strong>VoucherTableViewCell.xib</strong>
  <a href="https://i.stack.imgur.com/iW0f1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iW0f1.png" alt="enter image description here"></a></p>
  
  <p><strong>BrandTableViewCell.xib</strong>
  <a href="https://i.stack.imgur.com/yI3Yl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yI3Yl.png" alt="enter image description here"></a></p>
  
  <p>As you can see in VoucherTableViewCell I have two views "Código: AEB" and "Obtenla por". Now I have two classes for each <strong>VoucherTableViewCell</strong> and <strong>BrandTableViewCell</strong> and both have repetitive:</p>
  
  <p><strong>VoucherTableViewCell.swift</strong></p>
  
  <pre><code>protocol VoucherTableViewCellDelegate: class {
      func detailOptionTapped(id: String, description: String)
      func likeTapped(voucherId: String, reserved:Bool?, indexPath:NSIndexPath)
      func navigateToBrand()
  }
  
  class VoucherTableViewCell: UITableViewCell {
  
      var delegate:VoucherTableViewCellDelegate?
      var voucherId:String?
      var reserved:Bool?
      var indexPath:NSIndexPath?
      var brandId: String!
  
      @IBOutlet weak var voucherImageView: UIImageView!
      @IBOutlet weak var codeView: UIView!
      @IBOutlet weak var codeLabel: UILabel!
      @IBOutlet weak var hotDealView: UIView!
      @IBOutlet weak var hotDealLabel: UILabel!
      @IBOutlet weak var likeView: UIView!
      @IBOutlet weak var likeIconLabel: UILabel!
      @IBOutlet weak var likeNumberLabel: UILabel!
      @IBOutlet weak var brandLogoImageView: UIImageView!
      @IBOutlet weak var descriptionLabel: UILabel!
      @IBOutlet weak var detailView: UIView!
      @IBOutlet weak var detailIconLabel: UILabel!
      @IBOutlet weak var hotDealFlameIconLabel: UILabel!
      @IBOutlet weak var smartCoinIconLabel: UILabel!
  
      @IBAction func navigateToVoucherDetails(sender: UIButton) {
          self.delegate?.detailOptionTapped(voucherId!,description: descriptionLabel.text!)
      }
  
      @IBAction func likeTapped(sender:UIButton) {
          self.delegate?.likeTapped(voucherId!, reserved: reserved, indexPath: indexPath!)
      }
  
      @IBAction func navigateToBrand(sender: UIButton) {
          self.delegate?.navigateToBrand()
      }
  }
  </code></pre>
  
  <p><strong>BrandTableViewCell.swift</strong></p>
  
  <pre><code>protocol BrandTableViewCellDelegate: class {
      func showBrandDetails(id: String, description: String)
      func likeTapped(brandId: String, reserved:Bool?, indexPath:NSIndexPath)
  }
  
  class BrandTableViewCell: UITableViewCell {
      var delegate:BrandTableViewCellDelegate?
      var brandId:String?
      var reserved:Bool?
      var indexPath:NSIndexPath?
  
  @IBOutlet weak var brandImageView: UIImageView!
  @IBOutlet weak var likeButtonView: UIView!
  @IBOutlet weak var likeNumberLabel: UILabel!
  @IBOutlet weak var likeIconLabel: UILabel!
  @IBOutlet weak var brandLogoImageView: UIImageView!
  @IBOutlet weak var descriptionLabel: UILabel!
  @IBOutlet weak var detailButtonView: UIView!
  @IBOutlet weak var detailIconLabel: UILabel!
  
  @IBAction func showBrandDetails(sender: UIButton) {
      self.delegate?.showBrandDetails(brandId!,description: descriptionLabel.text!)
  }
  
  @IBAction func likeTapped(sender:UIButton) {
      self.delegate?.likeTapped(brandId!, reserved: reserved, indexPath: indexPath!)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>As you can see a lot of attributes and methods are repeated in both classes, and I would like to know how I can avoid this issue to reutilize my code as much as I can because when I am loading each element for both voucher and brand the code is similar.</p>
  
  <p>What can I do? I have no idea because I am a newbie in iOS development.</p>
  
  <p>Thanks in advance.</p>