ios - Why am I getting "[__NSArrayI allKeys]: unrecognized selector sent to instance" / why is NSDictionary transforming? -
looking [__nsarrayi allkeys]: unrecognized selector sent instance
error up, seemingly occurs when send nsarray allkeys
message meant nsdictionary
, in case i'm sending nsdictionary.
here's code use when interfacing pocket api:
nsdictionary *articles = [response objectforkey:@"list"]; // create array can use sort keys (and articles) in order of when added nsmutablearray *allkeys = [[articles allkeys] mutablecopy];
the last line there causes error. articles
declared nsdictionary? why not liking it?
oddly enough, if inspect @ runtime says it's nsarray! why did change?
(lldb) po articles $5 = 0x082103e0 <__nsarrayi 0x82103e0>( ) (lldb) po [articles class] $6 = 0x01b83b8c __nsarrayi (lldb)
it may declared in code dictionary, doesn't make dictionary. array , why exception. check response
know should expect.
your code compiles because compiler doesn't know it's going array , trusts dictionary. because objectforkey:
returns id
.
Comments
Post a Comment