On Oct 4, 2013, at 12:50 PM, Greg Parker <gpar...@apple.com> wrote:

> In practice you'll usually want to use NSObject<SomeProtocol>*

Well *there* is a solution I would never have thought of in a million years. 
I'm a bit surprised that so many built-in delegate properties in iOS (like, all 
of them, many dozens) are typed as id<SomeProtocol> rather than demonstrating 
this approach. Nor have I ever seen it in any of Apple's own example code. A 
good place for Apple to start would be the Utility Application template, which 
uses this .h file code:

@class FlipsideViewController;
@protocol FlipsideViewControllerDelegate
// ...
@end

@interface FlipsideViewController : UIViewController
@property (weak, nonatomic) id <FlipsideViewControllerDelegate> delegate;
// ...
@end

This uses (and teaches) none of the yummy goodness of either making the 
protocol adopt <NSObject> or of making the delegate an NSObject*.

As usual, thanks to all who answered; I learned a lot.

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do
iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to