• 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: drawRect using a Category
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawRect using a Category


  • Subject: Re: drawRect using a Category
  • From: Peter Teeson <email@hidden>
  • Date: Mon, 02 Apr 2012 11:31:44 -0400

Thank you all for your patience and kindness in educating me.
I appreciate it very much. I will sub-class which is what I have previously done.
This was, for me, a bit of an experiment (which failed). But that's also a good result.

Thanks again.

Peter
On 2012-04-02, at 12:44 AM, Jens Alfke wrote:
> On Mar 31, 2012, at 6:46 PM, Peter Teeson wrote:
>> In my app there is only the one NSMatrix instance
>
> There's no way to tell, really. For all I know, the Open or Save panels might use NSMatrix.
> Or the Find panel or the font panel. Heck, I believe in the old days of OpenStep,
> menus were implemented as NSMatrixes of menu item cells.
>
> Also, if you ever need to add another different NSMatrix somewhere else in your app,
> you're now SOL because you'll now have to rip out the category method and re-implement
> your code the right way using subclassing.
>
>> Although I do [super drawRect] after my own drawing.
>
> That won't call the old NSMatrix drawRect, it'll call the drawRect of the superclass of NSMatrix,
> which is NSControl. You've effectively deleted the original NSMatrix drawRect implementation,
> so it's impossible to call it without some tricky gymnastics. One more time: a category doesn't override
> a method, it replaces it. It literally edits the class's method table to replace the old function pointer with the new one.
> The only way to properly override a method, in the OOP sense, is to make a subclass.
>
> —Jens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Stenography
  • Next by Date: Re: Stenography
  • Previous by thread: Re: drawRect using a Category
  • Next by thread: Re: drawing lines in and NSTextView
  • Index(es):
    • Date
    • Thread