Re: Calling original method implementation from category
Re: Calling original method implementation from category
- Subject: Re: Calling original method implementation from category
- From: Yann Bizeul <email@hidden>
- Date: Mon, 25 Apr 2005 11:28:03 +0200
I thought a category won't let you override a method nor add static
or instance variable ?
I would use poseAsClass for this kind of stuffs.
I would be happy someone told us what is possible with categories :-)
Yann Bizeul • yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop • GeekTool • SSH Tunnel Manager • ...
http://projects.tynsoe.org/
Le 25 avr. 05 à 10:31, Georg Tuparev a écrit :
Folks,
I need to add a NSError category. The category implementation of -
domain needs to call the original NSError's -domain method. Here
what I am doing:
#import <objc/objc-class.h>
@implementation NSError (SELogEntry)
static IMP _originalDomainMethod = NULL;
+ (void)load {
Method originalMethod;
NSLog(@"===> Loading NSError category");
originalMethod = class_getInstanceMethod(self,@selector(domain));
if (originalMethod != NULL)
_originalDomainMethod = originalMethod->method_imp;
}
- (NSString *)domain {
if (_originalDomainMethod != NULL) return
(*_originalDomainMethod)(self, _cmd);
else return nil;
}
According to Anguish at all, this is supposed to work. But in
reality (*_originalDomainMethod)(self, _cmd) enters in an endless
recursion.
Any idea what I am doing wrong?
(using 10.3.8)
TIA
Georg Tuparev
Tuparev Technologies
Klipper 13
1186 VR Amstelveen
The Netherlands
Mobile: +31-6-55798196 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden