-2
我希望得到以下JSON我的阵列在UITableview
如何快速从dicitionary中获取数组的值?
{
MyPets = (
{
breed = "";
breedvaccinationrecord = "";
"city_registration" = "";
"date_of_birth" = "";
"emergency_contacts" = "";
gender = m;
"pet_id" = 475;
"pet_name" = "IOS PET";
petinfo = "http://name/pet_images/";
"prop_name" = "";
"qr_tag" = 90909090;
species = Canine;
"vaccination_records" = "";
vaccinationrecord = "http://Name/vaccination_records/";
"vet_info" = "";
}
);
}
显示我使用下面的代码来获得值到数组
if let dict = response.result.value {
print(response)
let petListArray = dict as! NSDictionary
self.petListArray = petListArray["MyPets"] as! [NSMutableArray]}
中的cellForRowAtIndexPath我使用这行中显示名称在的UILabel TableCell的
cell?.petName.text = self.petListArray[indexPath.row].valueForKey("pet_name") as? String
但它崩溃像
fatal error: NSArray element failed to match the Swift Array Element type
我是新来的SWIFT 2,请帮我在此先感谢
为什么有没有引号周围的随机密钥? –
这是从服务器响应,它在Android中正常工作,所以...我不知道多少 –