• 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
performSelector:withObject fails with class object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

performSelector:withObject fails with class object


  • Subject: performSelector:withObject fails with class object
  • From: Tron Thomas <email@hidden>
  • Date: Thu, 05 Feb 2009 21:50:43 -0800

I have a couple of classes that are delcared like this:

#import <objc/objc.h>
#import <objc/Object.h>

@interface SomeClass : Object
{
@private
	// Instance data members ...
}
+ (SomeClass*)instanceFromData:(id)data;
// Other methods ...
@end

@interface SomeOtherClass : Object
{
@private
	// Instance data members ...
}
+ (SomeOtherClass*)instanceFromData:(id)data;
// Other methods ...
@end

In yet another class, I have this function:

+ (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]; }

When the middle section of the function containing the class_copyMethodList is simply meant for verification, and prints:

instanceFromData

when the class name for either of the first two classes is provided. This seems to indicate the proper class object is being used and the expectation is that the call to performSelector:withObject: should succeed.

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?

_______________________________________________

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


  • Follow-Ups:
    • Re: performSelector:withObject fails with class object
      • From: Greg Parker <email@hidden>
    • Re: performSelector:withObject fails with class object
      • From: Ken Thomases <email@hidden>
  • Prev by Date: NSTask + incomplete stdout at end of process
  • Next by Date: Re: NSTask + incomplete stdout at end of process
  • Previous by thread: Re: NSTask + incomplete stdout at end of process
  • Next by thread: Re: performSelector:withObject fails with class object
  • Index(es):
    • Date
    • Thread