• 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: why isn't id<MyCellDelegate> an id?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >why isn't id<MyCellDelegate> an id? (From: Matt Neuburg <email@hidden>)
 >Re: why isn't id<MyCellDelegate> an id? (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: How to get variably sized header in a UICollectionView supporting both orientations
  • Next by Date: Re: Autolayout fixed size centering in VFL
  • Previous by thread: Re: why isn't id<MyCellDelegate> an id?
  • Next by thread: Doc Viewer in 5.0.1
  • Index(es):
    • Date
    • Thread