On 5/5/06, Vaisburd, Haim <[EMAIL PROTECTED]> wrote:
I would like to override a method of an existing class.
One way is to create a category and define a method
with the same name, e.g.
@interface NSBitmapImageRep (MyCategory)
 - destroy;
@end
Is there any way to call the original method
within the implementation of my override,
in this case the original [NSBitmapImageRep-destroy] ?

Try something like


static IMP originalDestroy;

@implementation NSBitmapImageRep (MyCategory)

+ (void) initialize
{
 Method_t destroy;
 static BOOL isInitialized = NO;

 [super initialize];
 if( isInitialized) return;

destroy = class_get_instance_method([NSBitmapImageRep class], @selector(destroy));

 originalDestroy = destroy->method_imp;

 isInitialized = YES;
}

void OriginalDestroy(id object)
{
 if( object) originalDestroy(object, @selector(destroy));
}

- (void) destroy
{
 OriginalDestroy(self);
}

@end

I do that to replace -description but with this I'm still able to use
the original

--
Chris


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to