• 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: Type Declaration With Protocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Type Declaration With Protocol


  • Subject: Re: Type Declaration With Protocol
  • From: Jeremy Pereira <email@hidden>
  • Date: Mon, 16 Mar 2009 11:22:43 +0000


On 14 Mar 2009, at 04:27, Roland King wrote:


As NSObject is also a protocol you could probably also do

id <NSObject, Protocol> to say the object supports NSObject and Protocol methods but I never do, partly because it doesn't seem as clear, partly because I know that I'm always going to pass something which is actually descended from NSObject, not just supporting that protocol and partly because the NSObject protocol doesn't have some of the NSObject methods I often end up using.

Or you can define your protocol as extending the NSObject protocol. e.g.

@protocol Foo <NSObject>

// Methods

@end






On Mar 14, 2009, at 12:13 PM, Richard Somers wrote:

The Objective-C 2.0 Programming Language documentation indicates that a type declaration for an object including a formal protocol should look something like this.

 id <Protocol> anObject;

I have been studying some sample code that does it like this.

 NSObject <Protocol> *anObject;

What is the difference between the two?

Richard

_______________________________________________

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

_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: Type Declaration With Protocol
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Type Declaration With Protocol (From: Richard Somers <email@hidden>)
 >Re: Type Declaration With Protocol (From: Roland King <email@hidden>)

  • Prev by Date: What's the best way to access top level objects loaded from a nib?
  • Next by Date: Re: What's the best way to access top level objects loaded from a nib?
  • Previous by thread: Re: Type Declaration With Protocol
  • Next by thread: Re: Type Declaration With Protocol
  • Index(es):
    • Date
    • Thread