Re: newbie Category question (what's the point?)
Re: newbie Category question (what's the point?)
- Subject: Re: newbie Category question (what's the point?)
- From: "Dennis C. De Mars" <email@hidden>
- Date: Fri, 18 Mar 2005 10:06:40 -0800
On Mar 16, 2005, at 9:37 AM, Mark Dawson wrote:
In the Sketch example, they've introduced a category:
@interface SKTGraphic (SKTEventHandling)
...
- (BOOL)hitTest:(NSPoint)point isSelected:(BOOL)isSelected;
...
@end
However, in the @implementation SKTGraphic, hitTest is defined (NOT a
separate @implementation SKEventHandling). SKTEventHandling doesn't
seem to be used anywhere else in the program.
What is the point of this? It seems that its just the same as putting
it in the @interface for SKTGraphic, with the effect (if I understand
categories) that hittest can't be subclassed in a subclass of
SKTGraphic.
Thanks for any enlightenment!
Mark
They do this to group and label related methods -- in this case the
SKTEventHandling category groups all methods of SKTGraphic that are
involved in event handling.
There is no runtime penalty for doing this -- hitTest:isSelected: will
be treated just the same as a method that was defined in the main
@interface section. And you are mistaken about the effect on
subclasses; subclasses of SKTGraphic can override the
hitTest:isSelected: method.
- Dennis D.
_______________________________________________
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