On or about 6/2/10 11:11 AM, thus spake "Greg Parker" <[email protected]>:
> 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 protected], 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 protected]) 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 [email protected]
