Replacing a method via categorys
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