I have code distributed in a library which looks like this:
if ([[NSString class] instancesRespondToSelector: @selector(JSONValue)]) {
NSString *jsonString = [[[NSString alloc] initWithData: jsonData encoding: NSUTF8StringEncoding] autorelease];
dict = [jsonString performSelector: @selector(JSONValue)];
}
For some reason a -[__NSCFString JSONValue]: unrecognized selector sent to instance
exception is getting thrown when the performSelector:
method gets called. This is code that is distributed in a library that I wrote, but I can't reproduce or debug it myself. Instead a third-party is reporting this problem. Under what conditions could instancesRespondToSelector:
while actually calling the method using performSelector:
throw an exception?
edit There is a case which could explain why this occurs, but it doesn't make sense. If the developers were to do something like this:
@implementation NSString (OurHappyCategory)
+ (BOOL)instancesRespondToSelector:(SEL)aSelector
{
return YES;
}
@end
It would explain why the code is executing, but it would of course be a very bad thing to do. Is there a way this problem could occur that makes sense?