views:

73

answers:

1

Why does this compile with out any errors or warnings?

@interface ObjectTest : NSObject {

}
-(void)iAmADoubleMethod;
-(void)iAmADoubleMethod;
@end

@implementation ObjectTest
-(void)iAmADoubleMethod {
    NSLog(@"IAmADoubleMethod");
}
@end

I came across this in a project I am working on. I come from a C++ background, so I figure I would get at least a warning for this. Not only would I like to know why it complies but could this code cause any problems?

Thanks.

+10  A: 

You're just declaring the method twice. The declarations don't conflict, so it's not a problem. It's the same as if you'd declared a function multiple times in a plain C or C++ program.

Chuck
I thought so, +1
darren
Thanks, maybe one day I will read the standards. Probably not :)
evanchri