Tuesday, August 7, 2012

How to use array in Xcode for noob?

Well, I have successfully created my object, now i want to create let say 20 object but I don't want to create them one by one, so by using array , i can create one array that contain 20 object

Since I am a noob, I will use array in a noob way

let say my object is Player

this is how i declare my new variable

Player *myplayer[20]


this is how i use them

for( int i=0 ; i<20 ; i++)
{
    [myplayer[i]  walk]
}


this mean i will loop through 20 object of Player and ask them all to walk



No comments:

Post a Comment