看起來這[__NSArrayI allKeys]: unrecognized selector sent to instance
錯誤,它似乎發生在您發送一個NSArray的allKeys
消息,這意味着爲NSDictionary
,但在這種情況下,我非常清楚地發送它到NSDictionary。爲什麼我得到「[__NSArrayI allKeys]:無法識別的選擇器發送到實例」/爲什麼NSDictionary轉換?
下面是與掌上API接口,當我使用的代碼:
NSDictionary *articles = [response objectForKey:@"list"];
// Create an array we can use to sort the keys (and thus the articles) in order of when they were added
NSMutableArray *allKeys = [[articles allKeys] mutableCopy];
最後一行有導致錯誤。但是articles
非常明確地聲明爲NSDictionary?爲什麼不喜歡它?
奇怪的是,如果我在運行時檢查它,它說它是一個NSArray!它爲什麼改變?
(lldb) po articles
$5 = 0x082103e0 <__NSArrayI 0x82103e0>(
)
(lldb) po [articles class]
$6 = 0x01b83b8c __NSArrayI
(lldb)
這可能是一個問題,你的指針指向一個NSMutable數組'allKeys'。看到這是一個方法名稱,它可能會導致一個問題。另外,你能否澄清'[迴應...'是什麼。 –
響應是來自Pocket API的JSON響應。 –