title: UITableView Mix of Static and Dynamic sections Cells ? throw error -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
body: <p>I am trying to create a UI table view that mixes Dynamic and Static cell section "something like WIFI settings views in ops". </p>
  
  <p>The first section will be static. It will hold the text field and labels. The second section will be dynamic it will show the members of the group.</p>
  
  <p>I get this exception:</p>
  
  <blockquote>
    <p><strong>* Terminating app due to uncaught exception 'NSRangeException', reason: '*</strong> -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond
    bounds [0 .. 0]'</p>
  </blockquote>
  
  <pre><code>class CreateGroupTableViewController: UITableViewController {
  // ----------
  // MARK: - Constants
  // ----------
  
  private struct Section{
      static let Static = 0
      static let Dynamic =  1
  }
  
  private struct CellId{
      static let Dynamic = "DynamicCell"
  }
  
  // ----------
  // MARK: - variables
  // ----------
   var users = [User]()
  
  // ----------
  // MARK: - Lifecycle
  // ----------
  
  override func viewDidLoad() {
  
      super.viewDidLoad()
  
      users = LibraryAPI.shared.getUsers()
  }
  
  // ----------
  // MARK: - UITableViewDataSource
  // ----------
  
   func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -&gt; Bool {
      return false
  }
  
  // ----------
  
   func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -&gt; Bool {
      return false
  }
  
  // ----------
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      if section == Section.Static {
          // count of your data source items
          return 3
      }
      else 
     if section ==  Section.Dynamic {
  
      let usercount = users.count
         print(String(users.count))
         return usercount
     }
      else {
          return super.tableView(tableView, numberOfRowsInSection: section)
      }
  }
  
  func tableView(_ tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell.EditingStyle {
      return .none
  }
  
  // ----------
  
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      print("test")
      if indexPath.section == Section.Dynamic
      {
          var cell = tableView.dequeueReusableCell(withIdentifier: "membersCell")
  
          if cell == nil {
              // create dynamic cell from xib or with default style
              cell = UITableViewCell(style: .subtitle, reuseIdentifier: "membersCell")
          }
  
          // customize your dynamic cell
          if let cell = cell
          {
               cell.textLabel?.text =  users[indexPath.row].username  // "srfsdf" 
              cell.detailTextLabel?.text = users[indexPath.row].email  //"users[0].email"
  
              return cell
          }
      }
      let cell = super.tableView(tableView, cellForRowAt: indexPath as IndexPath)
      return cell
  
  }
  </code></pre>
  
  <p>}</p>