Re: Replacing a method via categorys
Re: Replacing a method via categorys
- Subject: Re: Replacing a method via categorys
- From: Ofri Wolfus <email@hidden>
- Date: Tue, 28 Jun 2005 11:24:58 +0300
You may want to read this - http://cocoadev.com/index.pl?MethodSwizzling
It explains exactly what you want.
- Ofri
On 28/06/2005, at 00:48, Theodore H. Smith wrote:
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:
40gmail.com
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