• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Calling original method implementation from category
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Calling original method implementation from category
      • From: Ondra Cada <email@hidden>
    • Re: Calling original method implementation from category
      • From: Axel Andersson <email@hidden>
    • Re: Calling original method implementation from category
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: Re: NSFileModificationDate after 2039
  • Next by Date: [ANN] MyGraphView:NSView sample code available
  • Previous by thread: Re: NSFileModificationDate after 2039
  • Next by thread: Re: Calling original method implementation from category
  • Index(es):
    • Date
    • Thread