Re: Protocol-conforming object does not include retain?
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