• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: performSelector:withObject fails with class object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >performSelector:withObject fails with class object (From: Tron Thomas <email@hidden>)

  • Prev by Date: Re: NSTask + incomplete stdout at end of process
  • Next by Date: Re: performSelector:withObject fails with class object
  • Previous by thread: performSelector:withObject fails with class object
  • Next by thread: Re: performSelector:withObject fails with class object
  • Index(es):
    • Date
    • Thread