我从字典中获取值并需要在 UITableView 中显示,但一切正常。
在某些地方它停止运行并显示线程
-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0xbfa7670
下面的代码,我用来获取值..
[NSString stringWithFormat:@"%@",[[pageCat1 valueForKeyPath:@"img3"] objectAtIndex:indexPath.row]]
我的值在字典中正确提取但显示延迟?
pageCat (
{
img3 = "http://xxx.in/images/page_cat_img/75x75/4.jpg";
name = "PVC Flexible Wires";
page = (
{
id = {
text = 1;
};
img4 = "http://xxxx.in/images/page_img/75x75/1.jpg";
name = "SINGLE CORE FLEXIBLE WIRES ABOVE 6 SQMM";
},
{
id = {
text = 72;
};
img4 = "http://xxx.in/images/page_img/75x75/72.jpg";
name = "SINGLE CORE FLEXIBLE WIRES BELOW 6 SQMM";
}
);
},
{
img3 = "http://xxx.in/images/page_cat_img/75x75/3.jpg";
name = "Bare Copper Wires";
page = {
id = {
text = 29;
};
img4 = "http://xxx.in/images/page_img/75x75/29.jpg";
name = "Tinned Copper Fuse Wires";
};
},
{
img3 = "http://xxx.in/images/page_cat_img/75x75/48.jpg";
name = "Properties of Wire";
page = {
id = {
text = 85;
};
img4 = "http://xxx.in/images/page_img/75x75/85.jpg";
name = "Wires - Normal, HR - PVC, FR, FRLS & Zero Halogen";
};
}
)
实际看日志值,有数组和一组值。。我找不到它是什么形式的。。
谁能帮我找到解决方案??
谢谢, 亚日
最佳答案
它看起来像 [pageCat1 valueForKeyPath:@"img3"]
返回一个 NSString
而不是你期望的 NSArray
在应用 objectAtIndex
之前确保它返回一个 NSArray
:
pageCat1
似乎是一个 NSArray,所以你需要这样写:
NSString *path = pageCat1[0][@"img3"];
...
关于ios - 如何从嵌套数组/字典 iOS 7 中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24058376/