我无法访问放置在此plist中的数组:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>PageTitle</key>
<string>Title</string>
<key>Filters</key>
<array>
<dict>
<key>Filter</key>
<string>SomeFilter</string>
<key>Param</key>
<string>SomeParam</string>
</dict>
<dict>
<key>Filter</key>
<string>SomeFilter2</string>
<key>Param</key>
<string>SomeParam2</string>
</dict>
</array>
</dict>
</array>
</plist>
我的代码如下(路径设置正确):
NSMutableArray* propertyFile = [[NSMutableArray alloc] initWithContentsOfFile:path];
NSMutableDictionary* dict = [propertyFile objectAtIndex:0];
NSMutableArray* filters = [dict[@"Filters"] mutableCopy];
'dict'变量只返回一个键/值对,即'PageTitle'键。 “过滤器”键未被识别。对iOS来说很新,似乎正在试图解决这个问题。
答案 0 :(得分:0)
我刚刚运行了您的代码,我按预期获得了过滤器。您是否尝试在NSLog中打印过滤器?
2013-02-26 08:01:38.162 test[24849:c07] filters = (
{
Filter = SomeFilter;
Param = SomeParam;
},
{
Filter = SomeFilter2;
Param = SomeParam2;
}
)