【发布时间】:2012-07-28 22:37:00
【问题描述】:
我有一个包含多个同名键的 NSDictionary。这是结构:
Dictionary {
"Text" => "Blah",
"Text" => "Blah 2",
"Text" => "Blah 3"
}
所以有三个同名的键Text。我将Text 的值放入NSMutableArray 使用:
NSDictionary *notes = [d objectForKey:@"notes"]; //dictionary above
NSMutableArray *notesA = [notes valueForKey:@"Text"];
NSLog(@"%i", notesA.count);
但是,当我尝试获取数组中的项目数时,它会崩溃并出现以下错误:
-[__NSCFString count]: unrecognized selector sent to instance 0x856c110
知道为什么会这样吗?我能够输出NSMutableArray 的值并查看它们,但无法计算它们。
这是 XML 文件:
<tickets>
<text>Blah</text>
<text>Blah 2</text>
<text>Blah 3</text>
</tickets>
笔记字典输出:
(
{
text = "Blah";
},
{
text = "Blah 1";
},
{
text = "Blah 2";
}
)
【问题讨论】:
标签: objective-c ios cocoa-touch