开发者

Duplicate Method Names - Objective-c

Why does this compile with out any errors or warnings?

@interface ObjectTest : NSObject {

}
-(void)iAmADoubleMethod;
-(void)iAmADoubl开发者_运维问答eMethod;
@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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜