title: Multiple cells in UITableView With Different array sizes for each cell
body: <p>I'm working on a project in Swift 3.0 where I have a <code>UITableView</code> with three custom cells. In the first one I just have a label, in the second one I have an image plus a label along with expandable and collapsible headers.Thus I have three different sections for the second cell. And lastly the third one is also contains just a label. Im stuck at the delegate methods since these three cells returns three different arrays where the count is different that will return. The code I've done partially as bellow. As of now the code is only the second cell (which is working). But I think I've done the <code>cellForRow</code> method correctly. </p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,UIGestureRecognizerDelegate {
  
      @IBOutlet var tblSwift: UITableView!
  
      var arrayForTableView = ["swift","objective-c","c#","java"]
      var arrayForIcons = ["swift.jpeg","objectiveC.jpeg","csharp.jpeg","java.jpeg"]
      let dictSection = [["swift 1.0","swift 2.0","swift 3.0"],["objectiveC 1.0","objectiveC 2.0"],["C# 1.0","C# 2.0"],["java 1.0"]]
  
      let cellItentifir = "cellText"
      var expanedSections = [true, true, true, true]
  
      override func viewDidLoad() {
  
          super.viewDidLoad()
  
      }
  
      func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
          // The bellow code is for the expandable and collapsible cells
          return arrayForTableView[section]
      }
  
      func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
          let headerView : UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
          headerView.contentView.backgroundColor = UIColor.yellow.withAlphaComponent(1.0)
      }
  
      func tapped(sender: UITapGestureRecognizer)
      {   // The bellow code is for the expandable and collapsible cells
          if let tag = sender.view?.tag{
              expanedSections[tag] = !expanedSections[tag]
          }
          tblSwift.reloadData()
      }
  
      func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
  
          let headerView = UITableViewHeaderFooterView()
          headerView.tag = section
  
          let tapRecog = UITapGestureRecognizer(target: self, action: #selector(tapped))
  
          tapRecog.numberOfTapsRequired = 1
          tapRecog.numberOfTouchesRequired = 1
          tapRecog.delegate = self
          headerView.addGestureRecognizer(tapRecog)
          return headerView
      }
  
      func numberOfSections(in tableView: UITableView) -&gt; Int {
          return arrayForTableView.count
      }
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
  
          let isExpanded = expanedSections[section]
          if(!isExpanded) {
              return 0
          }
          return dictSection[section].count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          if indexPath.row == 0 {
          let cell = tableView.dequeueReusableCell(withIdentifier: "FirstCell")
               cell?.textLabel?.text = "First Cell"
              return cell!
          }else if indexPath.row == 1 {
          let cell = tableView.dequeueReusableCell(withIdentifier: self.cellItentifir)
          cell?.textLabel?.text = dictSection[indexPath.section][indexPath.row]
          cell?.imageView?.image = UIImage(named:arrayForIcons[indexPath.section])
          return cell!
          }else{
  
          let cell = tableView.dequeueReusableCell(withIdentifier: "ThirdCell")
              cell?.textLabel?.text = "Third Cell"
              return cell!
  
          }
      }
  </code></pre>