On or about 6/2/10 11:11 AM, thus spake "Greg Parker" <gpar...@apple.com>:

> 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.

But in fact I see now that UIAlertView works exactly this way; its delegate
is typed as id, not as id <UIAlertViewDelegate>. This explains why my class
never has to adopt UIAlertViewDelegate formally. Doubtless an alert view
with a delegate is *so* common that Apple felt it would drive the programmer
mad to have to adopt UIAlertViewDelegate formally all over the place.

m.

-- 
matt neuburg, phd = m...@tidbits.com, 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to