• 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: Categories, Protocols, Delegates and ToolTips
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Categories, Protocols, Delegates and ToolTips


  • Subject: Re: Categories, Protocols, Delegates and ToolTips
  • From: Marco Scheurer <email@hidden>
  • Date: Wed, 19 Jun 2002 18:08:54 +0200

On Wednesday, June 19, 2002, at 05:41 pm, Paul Cezanne wrote:
If you implement in a category methods that already exist, your implementation will replace the original, which could be risky.

why? As long as I call super I should be ok, no? (Ok, I can see how I might do stuff that would be "bad" but since I am adding functionality seperate from the control, I think I am ok here.)

No. If you send [super something] in a category of NSButton you will invoke NSButton's superclass (i.e. NSControl) implementation of 'something', not NSButton's implementation. NSButton implementation is lost.

(1) Subclass NSControl and either send an NSNotification or send an action to nil (it would then be caught by the first responder that can respond). For instance:

Right now I've done the subclassing via a Category like you (and Georg Tuparev) suggested and it works!

By chance, because it looks like you do not understand what is going on: you are not subclassing NSButton.

(3) Use poseAs: to replace NSControl with your subclass. poseAs: as the same ivar limitation as categories (you cannot add instance variables), but at you've got access to super's implementation. And you can do without ivar in that case.

I did some brief reading on this and it seemed fairly complicated.

[NSRolloverControl poseAsClass:[NSControl class]];

in your main file. Not fairly complicated, but poseAs: is a powerful thing, and like categories, should not be abused.

Georg's suggestion might be worth exploring too.

That reminds me, a lot of Cocoa is very cool, very powerful (I remember seeing a Next box at a trade show in the late 80s and thinking, man, that is the way to code.) but the coding paradigms are so different from C++ that the learning curve is very steep.

I would say that's good, because a steep learning curve brings you rapidly to the top, where as in C++ it takes 3 years. Seriously, I don't think that learning Cocoa is very difficult. Too bad that so many people exposition to objects come from C++ instead of Smalltalk.

Reading doesn't seem to help, coding seems to be the only way to do it. How do I convince my boss to send me to the Big Nerd Ranch and learn for a week. I've surely lost a week's worth in the past few months stumbling around.

I was a teacher for NeXTSTEP and DBKit classes, long ago. I'm certain that they were a very productive investment (and they were a lot of fun to teach). I believe that Aaron Hillegas of Big Nerd Ranch was behind these class syllabus. So either a week there or at one of Apple's Cocoa class could be productive.

Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Categories, Protocols, Delegates and ToolTips (From: Paul Cezanne <email@hidden>)

  • Prev by Date: Re: Categories, Protocols, Delegates and ToolTips
  • Next by Date: Corruption of text display in NSTextView
  • Previous by thread: Re: Categories, Protocols, Delegates and ToolTips
  • Next by thread: Re: Categories, Protocols, Delegates and ToolTips
  • Index(es):
    • Date
    • Thread