Re: performSelector:withObject fails with class object
Re: performSelector:withObject fails with class object
- Subject: Re: performSelector:withObject fails with class object
- From: Ken Thomases <email@hidden>
- Date: Fri, 6 Feb 2009 00:15:08 -0600
On Feb 5, 2009, at 11:50 PM, Tron Thomas wrote:
@interface SomeClass : Object
[...]
@interface SomeOtherClass : Object
[...]
However, when the performSelector:withObject: is executed, output
like the following is logged, and the program traps in the debugger:
*** NSInvocation: warning: object 0x1b0dc of class 'Object' does not
implement methodSignatureForSelector: -- trouble ahead
*** NSInvocation: warning: object 0x1b0dc of class 'Object' does not
implement doesNotRecognizeSelector: -- abort
What is needed to make this code work as expected?
SomeClass and SomeOtherClass need to inherit from NSObject rather than
Object.
+ (id)createInstanceForClass:
(const char*)className
withData:(id)data
{
id metaClass = ::objc_getMetaClass(className);
if(nil == metaClass){
return nil;
}
unsigned int count;
Method* method = ::class_copyMethodList(metaClass, &count);
for(unsigned int index = 0; index < count; ++index){
std::clog << ::sel_getName(::method_getName(method[index])) <<
std::endl;
}
return [metaClass performSelector:@selector(instanceFromData:)
withObject:data];
}
What's wrong with:
[NSClassFromString([NSString stringWithUTF8String:className])
instanceFromData:data];
?
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden