开发者

Duplicate Method Names - Objective-c

开发者 https://www.devze.com 2022-12-31 06:32 出处:网络
Why does this compile with out any errors or warnings? @interface ObjectTest : NSObject { } -(void)iAmADoubleMethod;

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

精彩评论

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