• 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: How To : Delegates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How To : Delegates (From: Owen McKerrow <email@hidden>)
 >Re: How To : Delegates (From: Ray Ackland <email@hidden>)
 >Re: How To : Delegates (From: Art Isbell <email@hidden>)
 >Re: How To : Delegates (From: Chuck Hill <email@hidden>)

  • Prev by Date: RE: NIB and Java Client
  • Next by Date: "Cron" a method
  • Previous by thread: Re: How To : Delegates
  • Next by thread: Re: How To : Delegates
  • Index(es):
    • Date
    • Thread