I'm totally new to Objective-C, so this might all be stupidly obvious.
I want to create and keep track of a bunch of objects (for example bullets). This is the code I'm currently using to create them.
for (int n=0; n<NUM_BULLETS; n++)
{
bullets[n] = [[BulletSprite alloc] init];
[self addChild:bullets[n]];
}
I also want to be able to reach the bullets I've created. For example, when I want to remove the bullets i use this:
for (int n=0; n<NUM_BULLETS; n++)
{
[bullets[n] die];
}
This works, but I get a warning "'Sprite' may not respond to '-die'", which I don't understand. I was messing around until I got it to work, but I don't think this is the proper way.
My question is: what is the 'right' way to create a bunch of objects and to send a message to each of them?