的價值。當從web服務的解碼JSON響應我得到一個錯誤說:無法投型「__NSArrayM」(0x34df0900)爲「NSDictionary的」 SWIFT
Could not cast value of type '__NSArrayM' (0x34df0900) to 'NSDictionary'
我嘗試了在StackOverflow上發現過這麼多的解決方案,但沒有任何工作。
我的代碼:從Web Service
let jsonData:NSDictionary = (NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers , error: &error) as? NSDictionary)!
let success:NSInteger = jsonData.valueForKey("success") as! NSInteger
響應:
[
{
"id": "1",
"title": "bmw",
"price": "500.00",
"description": "330",
"addedDate": "2015-05-18 00:00:00",
"user_id": "1",
"user_name": "CANOVAS",
"user_zipCode": "32767",
"category_id": "1",
"category_label": "VEHICULES",
"subcategory_id": "2",
"subcategory_label": "Motos",
"bdd": {}
}
]
謝謝您的幫助
我不在我面前,直到今晚,我會告訴你,今晚!感謝您的留言 ! – f1rstsurf
現在我有:「Binary operator'!='不能應用於'NSArray'類型的操作數?' 「和」nil「for」if jsonData [「message」] as?NSArray!= nil {「 – f1rstsurf
如何使用類似'NSArray.count> 0'的東西來檢查它是否爲空或空? –