Hi all
I am having trouble adding UIImageViews to a NSMutableArray.
in my .h file i have:
Code:
@interface iWackViewController : UIViewController {
NSMutableArray *monsterList;
}
@property (nonatomic) NSMutableArray *monsterList;
in my .m i try this:
Code:
CGRect myImageRect = CGRectMake(0, 0, 16, 16);
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
[myImage setImage:[UIImage imageNamed:@"monster.png"]];
myImage.opaque = YES;
[self.view addSubview:myImage];
[monsterList addObject:myImage];
NSLog(@"Monster added.");
NSLog(@"Array now %i elements long",monsterList.count);
But my array never grows - in the console i get "Monster added" followed by "Array now 0 elements long. The UIImageView is displayed just fine in the simulator.
Anyone know what i am doing wrong?
I want the array to be "public" i whatever you would call it in Objective C, which is why i define it in my .h
Thanks in advance.