I have written a function that adds a ball to an array yet when I check the count it hasnt increased, please can someone advise.
NSMutableArray *_otherBalls;
-(void)addBall{
CCSprite *target = [CCSprite spriteWithFile:@"redbouncyball.gif" rect:CGRectMake(0, 0, 27, 40)];
[self addChild:target];
//add to our array
[_otherBalls addObject:target];
NSLog(@"Added ball : %@",[_otherBalls count]);
}
The log comes out as
Added ball : (null)
From your code it seams that you have never initialized the array. So it’ cant store anything. Unless you did in init, but thats hard to guess.