Re: why isn't id<MyCellDelegate> an id?
Re: why isn't id<MyCellDelegate> an id?
- Subject: Re: why isn't id<MyCellDelegate> an id?
- From: Matt Neuburg <email@hidden>
- Date: Fri, 04 Oct 2013 20:12:48 -0700
On Oct 4, 2013, at 12:50 PM, Greg Parker <email@hidden> 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 = email@hidden, 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 (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