Vote count: 0
I'm trying to parse a JSON Url into a UICollectionView, but I keep getting Could not cast value of type '__NSArrayI' (0x1010ebd88) to 'NSDictionary' (0x1010ec288). as an error when I try to load the data. I am using xcode 8 with Swift 3.0. Can anybody see the error I am getting and how to fix it? Not sure where to go from here.
let link = "http://ift.tt/2kMkluf"
let urlString = link
let url = URL(string: urlString)
URLSession.shared.dataTask(with:url!) { (data, response, error) in
if error != nil {
print(error)
} else {
do {
let parsedData = try JSONSerialization.jsonObject(with: data!, options: []) as! [String:Any]
let currentConditions = parsedData["items"] as! [String:Any]
print(currentConditions)
let currentItem = currentConditions["link"] as! [String:Any]
print(currentItem)
} catch let error as NSError {
print(error)
}
}
}.resume()
asked 42 secs ago
Parsing JSON in Swfit 3.0 Cast NSArray to NSDictionary Error
Aucun commentaire:
Enregistrer un commentaire