discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question about categories


From: Chris Vetter
Subject: Re: A question about categories
Date: Mon, 08 May 2006 19:47:10 +0200

Hmm, I think my original mail never got through, so here's a re-sent:

On 2006-05-05 20:53:53 +0200 "Vaisburd, Haim" <HVaisbur@Advent.COM> wrote:
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 to provide some more information, but I'm still able to use the original -description, which I use to store in a dictionary.

--
Chris





reply via email to

[Prev in Thread] Current Thread [Next in Thread]