self?.viewModels.append(NewsTableViewCellViewModel(
companyName: result.first?.name ?? "",
name: result.first?.employees.first?.name ?? "",
phoneNumb: result.first?.employees.first?.phoneNumber ?? "",
skills: result.first?.employees.first?.skills ?? "")
)
\($0.data?.blocks?.first?.data.items?.first?.image.data.uuid)
print(self?.viewModels.first?.imageURL)
do {
let json = try JSONDecoder().decode(APIResponce.self, from: data)
let obj = json.result.items.filter{$0.data?.title != nil}
//
completion(.success(obj))
// completion(.success(json.result.items))
print("news: \(json.result.items.count)")
dump(json.result)
}
struct IsResult: Codable {
let items: [ResultItem]
let lastID, lastSortingValue: Int
enum CodingKeys: String, CodingKey {
case items
case lastID = "lastId"
case lastSortingValue
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
items = (try values.decode([ResultItem].self, forKey: .items))
lastID = (try values.decode(Int.self, forKey: .lastID))
lastSortingValue = (try values.decode(Int.self, forKey: .lastSortingValue))
/// Смапить items, которые ResultItem
let newItems = items.compactMap {_ in
guard let data = data else { return nil } }
// /и их и записать в items в инициализаторе
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return viewModels.count
}