【发布时间】:2015-05-02 02:31:06
【问题描述】:
我到处都读到目标 c 不支持方法重载,但我遇到了不同的结果。 我对方法重载的了解是“方法名称相同但参数不同”。
请试试这个:
接口文件
-(void)methodoverloading;
-(void)methodoverloading :(int)parameter;
实现文件
-(void)methodoverloading{
NSLog(@"methodoverloading method with no Parameter");
}
-(void)methodoverloading :(int)parameter{
NSLog(@"methodoverloading method with Parameter");
}
调用:
[self methodoverloading];
[self methodoverloading: 100];
结果:好的
2014-06-21 17:16:09.272 BasicFundamentals[869:a0b] methodoverloading method with no Parameter 2014-06-21 17:16:09.272 BasicFundamentals[869:a0b] methodoverloading method with Parameter
我在某处是对还是错?谢谢你
【问题讨论】:
标签: objective-c