• 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: Protocol-conforming object does not include retain?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Protocol-conforming object does not include retain?


  • Subject: Re: Protocol-conforming object does not include retain?
  • From: Bill Bumgarner <email@hidden>
  • Date: Fri, 11 Jul 2008 21:36:48 -0700

On Jul 11, 2008, at 8:52 PM, Markus Spoettl wrote:
The only thing that removes that warning (for me) is an informal protocol on NSObject that declares the method.

Meant to add this bit of code:

@interface NewRootClass
- (void) bobsYourUncle;
@end

int main (int argc, const char * argv[]) {
    NSObject *x = nil;
    id y = nil;

    [x bobsYourUncle]; // generates a warning
    [y bobsYourUncle]; // does not generate a warning

    return 0;
}

Note that NewRootClass is the declaration of a root class; a class that does not inherit from NSObject. The fact that the method is declared at all is enough for the compiler to assume that a variable of type (id) might just, in fact, respond to such a method.

This is exactly why the use of the type (id) is so uncommon. It grossly inhibits the compiler's ability to validate your code.

b.bum

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Protocol-conforming object does not include retain? (From: Steve Weller <email@hidden>)
 >Re: Protocol-conforming object does not include retain? (From: Bill Bumgarner <email@hidden>)
 >Re: Protocol-conforming object does not include retain? (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: Protocol-conforming object does not include retain?
  • Next by Date: Re: Protocol-conforming object does not include retain?
  • Previous by thread: Re: Protocol-conforming object does not include retain?
  • Next by thread: Re: Protocol-conforming object does not include retain?
  • Index(es):
    • Date
    • Thread