0
在我的Objective-C的項目,我有一個奇怪的,可以說,功能我有一個類,像這樣:靜態的Objective-C類是否必須繼承NSObject?
#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
會發生什麼事,當我通過代碼它工作正常步驟,但我得到在控制檯中神祕的錯誤(即使代碼是完全沒問題,按預期工作):
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
然而,即使它說中止,該代碼仍然有效。但是,當我不通過這些代碼行來運行它時,它會中止。發生了什麼,爲什麼?
噢好的..謝謝! – 2010-11-03 14:27:29