• 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: David Duncan <email@hidden>
  • Date: Fri, 04 Oct 2013 10:21:46 -0700

On Oct 4, 2013, at 9:59 AM, Matt Neuburg <email@hidden> wrote:

> Or, (2) inherit NSObject protocol back in the protocol definition:
>
> @protocol MyCellDelegate<NSObject>
> @end

You should do this.

> But why is either of those necessary? Surely an id<MyCellDelegate> is, by definition, an id

id<MyCellDelegate> is more specific than id, and so the compiler warns about calling methods that are not declared in MyCellDelegate.

> - which inherits from NSObject

id does not inherit from NSObject, it is just a generic object pointer. In many ways its a “get out of the type system free” card. But if you add type information to id by restricting it via a protocol, then you are requesting type checking.

> , and thus should solve the problem, just like casting to id. It is as if id<MyCellDelegate> is not an id, which makes no sense to me. Is this a Clang bug? Or am I just missing some fundamental truth?

--
David Duncan

_______________________________________________

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>)

  • Prev by Date: Re: C++ Function Call from Obj-C
  • Next by Date: Re: why isn't id<MyCellDelegate> an id?
  • Previous by thread: why isn't id<MyCellDelegate> an id?
  • Next by thread: Re: why isn't id<MyCellDelegate> an id?
  • Index(es):
    • Date
    • Thread