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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to