• 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: The Unadopted Protocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The Unadopted Protocol


  • Subject: Re: The Unadopted Protocol
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 02 Jun 2010 11:18:53 -0700
  • Thread-topic: The Unadopted Protocol

On or about 6/2/10 11:11 AM, thus spake "Greg Parker" <email@hidden>:

> On Jun 2, 2010, at 8:57 AM, Matt Neuburg wrote:
>> So this appears to be a technique for implementing a highly informal
>> protocol. (The technique is: define a protocol, don't bother adopting it
>> anywhere, but send messages defined in that protocol to an id.)
>
> Yep. When the compiler looks for a method declaration matching a message sent
> to `id`, it looks at every declaration encountered up to that point in the
> file.
>
> That's comparable to the traditional way to create informal protocols: declare
> a category on NSObject, don't bother implementing it anywhere, and send
> messages declared in that category to other objects.
>
> In general we discourage both of these now.

Fair enough; now that a protocol can declare some methods @optional, things
are pretty flexible.

But then I would just suggest that if you want to discourage a category on
NSObject as a way of doing informal protocols, you should discourage it; the
docs here teach it in a way that makes it sound perfectly acceptable:

<http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/Ob
jectiveC/Articles/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXRE
F147>

m.

--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



_______________________________________________

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

References: 
 >Re: The Unadopted Protocol (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: Delayed -dealloc occurs on worker thread if object is "working". How?
  • Next by Date: NSNumberFormatter setLocalizesFormat, docs wrong or implementation wrong?
  • Previous by thread: Re: The Unadopted Protocol
  • Next by thread: Re: The Unadopted Protocol
  • Index(es):
    • Date
    • Thread