Re: How To : Delegates
Re: How To : Delegates
- Subject: Re: How To : Delegates
- From: PA <email@hidden>
- Date: Thu, 27 Jan 2005 11:23:49 +0100
On Jan 27, 2005, at 01:46, Chuck Hill wrote:
Thanks to whoever at Apple dreamt that up and implemented it.
Well... no one at Apple "dreamed it up"... as it awkwardly tries to
emulate what is known as "informal" protocols in Objective-C:
http://www.toodarkpark.org/computers/objc/moreobjc.html
In "Cocoa", this is very straightforward to implement as it boils down
to a -respondsToSelector: method call. Check NSObject's protocol for
details:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Protocols/NSObject.html
To achieve the same effect in Java is "mucho" more convoluted as there
is no straightforward equivalent to something like a @selector and
respondsToSelector:...
FWIW, here is my own concoction of such generic "delegate":
http://cvs.sourceforge.net/viewcvs.py/zoe/ZOE/Frameworks/SZFoundation/
SZDelegate.java?view=markup
Alternatively, and if you are strongly allergic to anything "open
source", feel free to attempt to decipher the innards of
com.webobjects.foundation._NSDelegate.
In practice, and considering the amount of pain and magic involved in
implementing such a construct in Java, "informal protocols" are of
limited use in Javalalaland.
Plus, they are of very questionable value in the first place. After
all, Java is not Objective-C. Trying to emulate one language behavior
with the other is mostly self defeating (defatting?). As always, YMMV.
Cheers
--
PA
http://alt.textdrive.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden