Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问嵌套的NSDictionary 10.8 SDK v 10.7 SDK_Nsdictionary - Fatal编程技术网

访问嵌套的NSDictionary 10.8 SDK v 10.7 SDK

访问嵌套的NSDictionary 10.8 SDK v 10.7 SDK,nsdictionary,Nsdictionary,我已经编写了一个方法来访问存储在plist中的嵌套字典。在10.8编译器上运行良好,但在10.7编译器上出现以下错误: 在对象类型“NSDictionary*”上找不到读取字典元素的预期方法 plist具有以下结构: <dict> <key>15.144.15</key> <dict> <key>Message</key> <string>15</string> <key

我已经编写了一个方法来访问存储在plist中的嵌套字典。在10.8编译器上运行良好,但在10.7编译器上出现以下错误:

在对象类型“NSDictionary*”上找不到读取字典元素的预期方法

plist具有以下结构:

<dict>
<key>15.144.15</key>
<dict>
    <key>Message</key>
    <string>15</string>
    <key>X</key>
    <real>484.8828125</real>
    <key>Y</key>
    <real>104</real>
</dict>
<key>15.144.17</key>
<dict>
    <key>Message</key>
    <string>17</string>
    <key>X</key>
    <real>612.91796875</real>
    <key>Y</key>
    <real>190.6484375</real>
</dict>
</dict>
我假设10.8SDK以这种方式处理对嵌套字典的访问,但10.7没有

有人知道一种方法可以兼容两种SDK吗


感谢使用10.8 SDK编译并将部署目标设置为10.7。这是向后部署到10.6。你的语法错了,tho。不要将变量名括在方括号中,只包含下标键:

NSValue* value = dictionary[@"parentKey"][@"nestedKey"];

谢谢Jason,是部署目标解决了我的问题。顺便说一句,语法对于我如何使用它是正确的:[self methodToReturnDict][methodInputParameter][constant]@lymdo这是真的,但这不是问题代码中的内容,所以我只是指出它。
NSValue* value = dictionary[@"parentKey"][@"nestedKey"];