title: how to display the data in tableviewsection using mvvm
body: <p>I have  problem while creating the model.</p>
  
  <p>My api is in such way.</p>
  
  <pre><code>{data:["name":"seena","option":["Yes, always","no"]]}
  </code></pre>
  
  <p>so according to this i need to display the data in tableviewsection using mvvm way.</p>
  
  <p>Here i need two create two model 
  1.for question list 
  2.options list </p>
  
  <p>mymodel:-</p>
  
  <pre><code>class QuestionListModel: NSObject {
  
      var home:[OPTIONS] = []
  
      var id:Int!
      var question:String!
      var options:[String]?
      var v:String?
  
  
  
      init(dictionary :JSONDictionary) {
  
          guard   let question = dictionary["question"] as? String,
                  let id = dictionary["id"] as? Int
               else {
                  return
  
          }
  
  
  
  
          if let options = dictionary["options"] as? [String]{
              print(options)
  
             print(options)
  
  
          }
  
  
          self.question = question
          self.id = id
                  }
  
  }
  </code></pre>
  
  <p>in viewmodel:-</p>
  
  <pre><code>  func numberOfSections(tableView: UITableView) -&gt; Int{
          print((datasourceModel.dataListArray?.count)!)
          return (datasourceModel.dataListArray?.count)!
      }
  
      func titleForHeaderInSection(atsection section: Int) -&gt; QuestionListModel {
          return datasourceModel.dataListArray![section]
      }
  
  
      func numberOfRowsInSection(section:Int) -&gt; Int {
          print(self.tableArray[section].count)
          return self.tableArray[section].count
      }
  </code></pre>
  
  <p>and in the viewcontroller as:-</p>
  
  <pre><code> func numberOfSections(in tableView: UITableView) -&gt; Int {
          return reviewViewModel.numberOfSections(tableView: tableView)
      }
  
  
      func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
  
  
        //  let headercell = Bundle.main.loadNibNamed("HeaderCell", owner: self, options: nil)?.first as! questionheader
  
  
          let identifier = "HeaderCell"
  
          var headercell: questionheader! = tableView.dequeueReusableCell(withIdentifier: identifier) as? questionheader
  
          if headercell == nil {
              tableView.register(UINib(nibName: "questionheader", bundle: nil), forCellReuseIdentifier: identifier)
              headercell = tableView.dequeueReusableCell(withIdentifier: identifier) as? questionheader
          }
  
          headercell.setReviewData(reviews:reviewViewModel.titleForHeaderInSection(atsection:section))
  
  
  
  
          return headercell
      }
  
  
  
      func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat {
  
          return 63
  
      }
  
  
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          // 2
          //return 1
  
          return reviewViewModel.numberOfRowsInSection(section: section)
      }
  
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
  
          let identifier = "Cell"
          var cell: QuestionListCell! = tableView.dequeueReusableCell(withIdentifier: identifier) as? NH_QuestionListCell
  
          if cell == nil {
              tableView.register(UINib(nibName: "NH_QuestionListCell", bundle: nil), forCellReuseIdentifier: identifier)
              cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? QuestionListCell
          }
          cell.contentView.backgroundColor = UIColor.clear
  
  
          print(reviewViewModel.tableArray)
  
          if (reviewViewModel.type == "1"){
  
  
              cell.imagebutton.setImage(UIImage(named: "radio_uncheck.png"), for: .normal)
  
          }
          else{
  
  
              cell.imagebutton.setImage(UIImage(named: "radio_uncheck.png"), for: .normal)
          }
  
  
         if let tempArray = reviewViewModel.tableArray[indexPath.section] as? [String] {
  
          print(tempArray)
  
          let values = tempArray[indexPath.row]
  
  
  
  
          print(values)
          cell.question.text = values
  
  
          }
  
          return cell
           }
  </code></pre>
  
  <p>And how to display data of options in tableviewcell</p>