I have the values as:-
[[yes,no],[yes,no]]
i need to display in cellForRowAt indexPath in tableview .
my code:-
var tableArray:Array<[String]> = []
fetching the data from JSON:-
if let data = wholedata["data"] as? Array<[String:Any]>{
print(data)
print(response)
for question in data {
let options = question["options"] as! [String]
self.tableArray.append(options)
// self.fetchedHome.append(options as! [home])
self.no = options.count
}
print(self.tableArray)
my cell for row at index in tableview :-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "Cell"
var cell: QuestionListCell! = tableView.dequeueReusableCell(withIdentifier: identifier) as? QuestionListCell
if cell == nil {
tableView.register(UINib(nibName: "QuestionListCell", bundle: nil), forCellReuseIdentifier: identifier)
cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? QuestionListCell
}
print(reviewViewModel.tableArray)
cell.question.text = "hai"
} else {
return UITableViewCell()
}
}
How to display the data in the tableview cell?