Basically I create an array and add instances of my custom class to it. But when i try to access properties of the instances stored in the array, I get no response from the class. Btw, it works with regular instances of a class.
//This works:
Laser *myLaser = [[Laser alloc] initWithPosX:100 Y:150 node:self];
myLaser.sprite.rotation = 50; //This changes the sprite¨s (the sprite inside the class) rotation
//This doesnt:
Laser *aLaser = [[Laser alloc] initWithPosX:100 Y:150 node:self];
[Lasers addObject:aLaser]; //Lasers is a NSMutableArray declared in the .h
[aLaser release];
Laser *copyLaser = [Lasers objectAtIndex:0];
copyLaser.sprite.rotation = 50; //For some reason this doesnt work!
Does anyone know why it doesnt work? Is it a problem with using NSMutableArray?, my class is an NSObject.
The problem I see here is that
Lasersis not initialized and is nil here.You have to initialize
Laserssomewhere (probably just before you use it or in your init method of your view controller). Use[[NSMutableArray alloc] init].