亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

objective-c開發(fā)問題~新手
黃舟
黃舟 2017-04-24 09:11:31
0
3
500
- (void) setTire: (Tire *) tire
         atIndex: (int) index
{
    [tires replaceObjectAtIndex: index
           withObject: tire];

} // setTire:atIndex:


- (Tire *) tireAtIndex: (int) index
{
    Tire *tire;
    tire = [tires objectAtIndex: index];

    return (tire);

} // tireAtIndex:

這是objective-c基礎(chǔ)教程里面的代碼
我就是不理解這段什么意思 尤其是(Tire *) tireAtIndex: (int) index這一塊 求指教!謝謝!

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(3)
伊謝爾倫

It’s just an array setter/getter, but the syntax of OC is written like this. You should be able to see it clearly if written in other syntax.
This is equivalent to this writing method in C language

cvoid setTire(Tire tire,int index){
    tires[index]=tire;
}
Tire setTire(int index){
    return tires[index];
}

or JAVA

javapublic void setTire(Tire tire,int index){
    tires[index]=tire;
}
public Tire tireAtIndex(int index){
    return tires[index];
}

apple new language swift

swiftfunc setTire(tire:Tire,index:Int){
    tires[index]=tire;
}
func tireAtIndex(index:Int)->Tire{
    return tires[index];
}

JS with Arrow Function

javascriptvar setTire=(tire,index)=>tires[index]=tire;
var tireAtIndex=(index)=>tires[index];
迷茫

I’m also confused as to why someone writes code like this. And it’s a tutorial. Isn’t this misleading to newbies? It’s not a Setter Getter method, it’s just two ordinary methods. The function of the method is similar to setting the object of a certain item in the array, and getting the object of a certain item

迷茫

Now you no longer need to define instance variables and write access methods, just use properties directly!
The tutorials you are watching are probably from 3 years ago.

For tutorials on properties, you can visit our blog about the introduction of properties

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template