Re: Customizing controls: Inheritance bad?
Re: Customizing controls: Inheritance bad?
- Subject: Re: Customizing controls: Inheritance bad?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 30 Oct 2008 18:29:45 +0100
Le 30 oct. 08 à 16:51, Brian Williams a écrit :
Hello,
I'm brand new to Cocoa/Obj-C and I'm working on converting an app. to
use Cocoa...
I've heard that, in general, if you are using inheritance in Cocoa,
you're not following the typical standard design pattern. Is this
true?
To respond to special keyboard events in an NSTableView, I created a
subclass and provided an implementation for keyDown.
To draw some customized stuff in an NSColorWell, I created a subclass
and provided an implementation for drawRect.
Etc.
In the olden days, this kind of object-oriented approach was perfectly
correct.
And it's always perfectly correct. That's the way to do it.
But I'm told I should be using delegate methods and firstResponders
somehow.
Yes, use them when they provide a way to do what you need (and it's
often the case), but they do not fit for some kind of customization
(like custom drawing).
_______________________________________________
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