Ожидается использование нескольких массивов при использовании tableView. Сначала с точки OOP необходимо создать 1 модель, например
struct Root: Codable {
let catID, catName, catParentid, year,name: String?
enum CodingKeys: String, CodingKey {
case catID = "cat_id"
case catName = "cat_name"
case catParentid = "cat_parentid"
case year, name
}
}
, и использовать Codable
для анализа json * 1007.*
var arr = [Root]()
do {
let content = json["content"] as! [[String:String]]
let staData = try JSONSerialization.data(withJSONObject:content,options:[])
arr = try JSONDecoder().decode([Root].self, from:staData)
}
catch {
print(error)
}
в числе строк
return arr.count
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MyCustomCell
let item = arr[indexPAth.row]
cell.cat_id.text = item.catID
cell.cat_name.text = item.catName
cell.cat_parentid.text = item.catParentid
cell.name.text = item.name
cell.year.text = item.year
return cell
}