Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2584956
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5920
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: iOS平台

2015-09-14 10:20:05

oc没有严格的方法重载.在oc中,方法名不允许相同。比如
-(void) test:(int) intValue;
-(void) test:(float) floatValue;
在oc中是不允许的,因为它们的名字都是test:,注意,名字要包括后面的冒号。
所以在oc 中的重载应该是指参数个数不同,但是返回类型后面的名字相同。
或者是 参数个数相同,但是其标签不相同。
-(void) test:(int) intValue;
-(void) test:(float) floatValue; //错误,与第一个方法重名(test:)
-(void) test:(int) x andY:(int) y;
-(void) test:(int) x andY:(double) y;//错误,还是重名了(test:andY:)
-(void) test:(int) x :(double) y;  //正确,名字不同,
阅读(836) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~