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

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to