Answer the question
In order to leave comments, you need to log in
How to pass data to viewModel?
There are two variables
private var result = [Company]()
private var viewModels = [NewsTableViewCellViewModel]()
struct APIResponce: Codable {
let company: Company
}
struct Company: Codable {
let name: String
let employees: [Employee]
}
private func fetchPeople(completed: ((Bool) -> Void)? = nil) {
APICaller.shared.getTopStories { [weak self] json in
switch json {
case .success(let result):
self?.result.append(contentsOf: result)
// не могу положить данные
// self?.viewModels.append(contentsOf: result ({ viewModels in
// return NewsTableViewCellViewModel()
// }))
}
}
}
Answer the question
In order to leave comments, you need to log in
Read the text of the error - it says that it is not possible to assign an object of type TYPE to type [TYPE].
Those. - banal type mismatch. You are trying to assign one object to a variable that contains an array of objects.
upd. An error was found - skills is an array, and the author assigned a line to it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question