• 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
Re: newbie Category question (what's the point?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >newbie Category question (what's the point?) (From: Mark Dawson <email@hidden>)

  • Prev by Date: Re: NSDrawerWindow - using it is okay?
  • Next by Date: Re: NSImage drawInRect:fromRect:
  • Previous by thread: newbie Category question (what's the point?)
  • Next by thread: Text view (in custom view) - moving ruler markers below zero?
  • Index(es):
    • Date
    • Thread