为了账号安全,请及时绑定邮箱和手机立即绑定

objective-c开发问题~新手

objective-c开发问题~新手

慕田峪9158850 2019-04-16 20:28:00
-(void)setTire:(Tire*)tireatIndex:(int)index{[tiresreplaceObjectAtIndex:indexwithObject:tire];}//setTire:atIndex:-(Tire*)tireAtIndex:(int)index{Tire*tire;tire=[tiresobjectAtIndex:index];return(tire);}//tireAtIndex:这是objective-c基础教程里面的代码我就是不理解这段什么意思尤其是(Tire*)tireAtIndex:(int)index这一块求指教!谢谢!
查看完整描述

2 回答

?
ITMISS

TA贡献1871条经验 获得超8个赞

就是个数组的setter/getter,只不过OC的语法就这样写,用其他语法写出来你应该能看清楚了。
相当于C语言的这种写法
cvoidsetTire(Tiretire,intindex){
tires[index]=tire;
}
TiresetTire(intindex){
returntires[index];
}
或者JAVA
javapublicvoidsetTire(Tiretire,intindex){
tires[index]=tire;
}
publicTiretireAtIndex(intindex){
returntires[index];
}
apple新语言swift
swiftfuncsetTire(tire:Tire,index:Int){
tires[index]=tire;
}
functireAtIndex(index:Int)->Tire{
returntires[index];
}
JSwithArrowFunction
javascriptvarsetTire=(tire,index)=>tires[index]=tire;
vartireAtIndex=(index)=>tires[index];
                            
查看完整回答
反对 回复 2019-04-16
?
有只小跳蛙

TA贡献1824条经验 获得超8个赞

我也很困惑为啥有人这样写代码。而且还是教程,这不是误导新手吗
不是啥SetterGetter方法,就是普通的两个方法,方法的功能就是类似设置数组的某项的object,和获取某项的object
                            
查看完整回答
反对 回复 2019-04-16
  • 2 回答
  • 0 关注
  • 558 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信