{
Items = {
Item = {
text = "item 1";
}
Item = {
text = "item 2";
}
Item = {
text = "item 3";
}
}
}
上面是我的NSDictionary的一個例子。記住這個下一個片段。NSDictionary長度計數是錯誤的
NSDictionary *dict = {the afore mentioned dictionary is here}
int count = [[[dict objectForKey:@"Items"] allKeys] count]; // Breakpoint here
NSLog(@"%i", count); // Breakpoint here
在我的斷點,我得到了count
- 以下值在斷點1:
count = (int) 128037184
(或其他一些隨機的,大INT) - 在斷點2:
count = (int) 5
我本來期望兩次的int都是3。這是怎麼回事?
你可以發佈你建立NSDictionary的代碼嗎? – 2012-02-01 17:44:30
當你在第2行有斷點時,'count'可能是準備好的,但並不準確計算。這可能是一個隨機int的原因,我猜? – 2012-02-01 17:45:53