的价值。当从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'的东西来检查它是否为空或空? –