Could not cast value of type '__NSArrayI' (0x10df73c08) to 'NSDictionary' (0x10df74108) Could not cast value of type '__NSArrayI' (0x10df73c08) to 'NSDictionary' (0x10df74108) arrays arrays

Could not cast value of type '__NSArrayI' (0x10df73c08) to 'NSDictionary' (0x10df74108)


Your response is of Array of Dictionary not Dictionary, so if you want all the dictionary you can access it using loop.

if let array = response.result.value as? [[String: Any]] {    //If you want array of task id you can try like    let taskArray = array.flatMap { $0["task_id"] as? String }    print(taskArray)}


That's because you service returns results in form of an array. What you need to do is to cast result to NSArray. Then you can access separate results by index:

let JSON = result as! NSArraylet firstResult = results[0]


Swift 4.1 +

if let resultArray = jsonResponse.result.value as? [[String: Any]] {    let taskArray = resultArray.compactMap { $0["task_id"] as? String }}