Hacker News new | ask | show | jobs
by andrewroycarter 4781 days ago
You can test easily! [array isKindOfClass:[NSMutableArray class]] or [array respondsToSelector:@selector(insertObject:)]
2 comments

Have you actually tried it? Because the people who have (me included) found that both tests will return YES, yet when you try a mutable operation you get an exception.

http://stackoverflow.com/questions/1788690/objective-c-how-t...

http://www.cocoabuilder.com/archive/cocoa/224795-nsdictionar...

You cannot use `isKindOfClass:` to introspect an array like this. Most of the toll-free bridged foundation classes such as arrays/dictionaries/sets are implemented as class clusters.