I have such array in from api:
[{
data = "";
datetime = "23.07.2020 12:09";
id = 340593;
status = "My current task is";
},...]
I have created such struct:
struct RemarksModel {
let id:Int
let status,datetime:String
let data:String?
}
And here I make request:
AF.request(URLRequest(url:Pathes.init(endpoint: "notepad/\(noteModel?.id ?? 0)/documentation").resourseUrl),
interceptor: CallInterceptor.init(method:HTTPMethod.get)).responseJSON(completionHandler: { (response) in
print(response.description)
switch response.result{
case .success(let array):
let remarksData = array as? [RemarksModel]
let json = response.data as? [RemarksModel]
print(json?.count)
// if remarksData?.count ?? 1 > 0{
// self.remarksArray += remarksData!
// self.tableView.reloadData()
// }
case .failure(let error):
print(error.localizedDescription)
}
})
the problem is that I can't convert this array to array of my model objects. when I try to add all received data to array my app crashes because my array is nil, despite of json in logs. Maybe I have to use another way of converting received json array to objects array?