Calling original method implementation from category
Calling original method implementation from category
- Subject: Calling original method implementation from category
- From: Georg Tuparev <email@hidden>
- Date: Mon, 25 Apr 2005 10:31:55 +0200
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(@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