I'm finding it very difficult to pass my result in my completion callback to access in my ViewController. I can print my object when I do my for loop but I cant access specific values inside the object.
public func getMedia(completion: @escaping (Array<Any>) -> ()){
Alamofire.request(URL(string: MEDIA_URL)!,
method: .get)
.responseJSON(completionHandler: {(response) -> Void in
if let value = response.result.value{
let json = JSON(value).arrayValue
completion(json)
}
}
)
}
In my ViewController
getMedia(){success in
for item in success{
print(item["image"]) //This causes error
print(item) //This prints the object perfectly
}
}