Reputation: 55583
In my objective-c project, I have a weird, lets say, feature I have a class, like this:
#import <Foundation/Foundation.h>
@interface Convert /* : NSObject */ // <--- is that necessary?
+(int) toInt:(id) obj;
@end
@implementation Convert
+(int) toInt:(id) obj
{
return [obj intValue];
}
@end
What happens is, when I step through the code It works fine, but I get a cryptic error in the console (even though code is completely fine, works as expected):
2010-11-03 09:35:49.422 Tests[14066:5f03] *** NSInvocation: warning: object 0x9e424 of class 'Convert' does not implement methodSignatureForSelector: -- trouble ahead
2010-11-03 09:35:49.422 Tests[14066:5f03] *** NSInvocation: warning: object 0x9e424 of class 'Convert' does not implement doesNotRecognizeSelector: -- abort
Yet, even when It says abort, the code still works. However, when I run it without stepping through those lines of code, it aborts. What Is happening and why?
Upvotes: 1
Views: 333
Reputation: 28242
The simple answer is "yes".
Or more specifically, the runtime expects objects to conform to the NSObject
protocol, and the simplest way to do this is by making sure your objects inherit from the NSObject
class.
Upvotes: 2