• 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
Replacing a method via categorys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Replacing a method via categorys


  • Subject: Replacing a method via categorys
  • From: "Theodore H. Smith" <email@hidden>
  • Date: Mon, 27 Jun 2005 22:48:38 +0100


I'm trying to replace a method in NSCell, via categories.

First off, let me say I know this is usually a very bad thing to do. Mostly if done wrong, I can introduce bugs into perfectly good code. And also if Apple ever change NSCell, my code might break in the future.

Anyhow, just for experiments sake and assuming I'm responsible for the dangers, I have this question.

If I want to replace a method in a category, how can I get that replacement method to call the original method?


@implementation NSCell (NoHilite)
- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView: (NSView *)controlView {
if (controlView != IgnoredHilite) {
[super highlight:flag withFrame:cellFrame inView:controlView];
}
}


@end

Here I get a compile time error that [super highlight:flag withFrame:cellFrame inView:controlView]; is bad. I'm not sure if it is possible even to call the original method.

Also, the method doesn't even get called (I set breakpoints), and my cells get hilited normally.

Any clues anyone?

--
http://elfdata.com/plugin/ Industrial strength string processing, made easy.


"All things are logical. Putting free-will in the slot for premises in
a logical system, makes all of life both understandable, and free."

_______________________________________________
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: Replacing a method via categorys
      • From: Pandaa <email@hidden>
    • Re: Replacing a method via categorys
      • From: Ofri Wolfus <email@hidden>
    • Re: Replacing a method via categorys
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Why add a nil item to an NSArray ?
  • Next by Date: Re: Replacing a method via categorys
  • Previous by thread: Help with centering custom views in NSTabView
  • Next by thread: Re: Replacing a method via categorys
  • Index(es):
    • Date
    • Thread