-2
我發現很難將我的結果傳遞給我的完成回調以訪問我的ViewController。我可以打印我的對象,當我做我的循環,但我不能訪問對象內的特定值。類型任何沒有下標成員
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)
}
}
)
}
在我的ViewController
getMedia(){success in
for item in success{
print(item["image"]) //This causes error
print(item) //This prints the object perfectly
}
}