Re: OBJ-C question
Re: OBJ-C question
- Subject: Re: OBJ-C question
- From: Kay Roepke <email@hidden>
- Date: Sat, 17 Apr 2004 19:55:41 +0200
On 17. Apr 2004, at 19:37 Uhr, Sherm Pendley wrote:
There's also efficiency to consider - without a default
implementation, you have to call respondsToSelector: before each call
to a data source method. You couldn't simply call it in setDataSource:
because the method could be added to the class after the data source
object has been assigned. Not only would this clutter up your code, it
would introduce a bottleneck in what is usually a frequently-called
time-critical method.
A pattern I've seen quite often in Apple's headers (I think it was in
Xcode class-dumps. Not too sure anymore where it was...) is
to have a struct in which the result of respondsToSelector: (i.e.
YES/NO) is saved.
This way you do not have the overhead of a method dispatch like you do
if you have a dummy method somewhere in your ancestry.
You would check for the supported methods in your setDelegate: method
and whenever you want to call the delegate methods have a check
if it's ok to send the message.
Kay
_______________________________________________
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.