Previously in my app when I was making a call to the server and if there was an error I would do the following:
Alamofire.request(mutableURLRequest).responseJSON{
response in if let JSON = response.result.value{
if JSON.count != 0{
let errorList = JSON["responseErrorsList"] as? NSArray
for error in errorList!{
let erro: String = error as! String
switch erro{
case "EntityRequired":
With the migration from swift 2 to swift 4 I am having problems because theList errors comes to nil however the result of JSON is as follows:
["Rate":, "Level":, "Code":, "ID": 0, "Zone":, "Address":, "ErrorsListServer": ( InvalidCode ) , "SubZone":]
Someone knows how I can access the "ErrorsListServer" field and fetch the errors that in this case is "InvalidCode".
What I have implemented and is not working for is the following:
if let JSON = response.result.value as? [String: Any]{
if (JSON as AnyObject).count != 0{
let errorList = JSON["responseErrorsList"] as? [[String: Any]]