[Solved] “-[__NSDictionaryI length]: unrecognized selector sent to instance” error without NSDictionary?


[NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error:&error];

is never returning a string. Either a NSArray or a NSDictionary. (The documentation only promises: A Foundation object from the JSON data in data, or nil if an error occurs. So it might be another type in future).

You error starts with

-[NSDictionaryI length]:

so in your case it is a dictionary (NSDictionaryI is a concrete immutable subclass of NSDictionary).

Just because you type the variable NSString it doesn’t change the object assigned to it.

1

solved “-[__NSDictionaryI length]: unrecognized selector sent to instance” error without NSDictionary?