Hello to everybody
I am trying to create an app, and in this app I will need to hold a lot of images for a UIImageView.
Creating different variables for each image I want to load isn't hard, but it's not the right way to load many images.
So I'm trying the following:
Code:
NSMutableArray *images; //global variable in .m file
- (void)viewDidLoad {
images = [NSMutableArray arrayWithCapacity:30];
for(NSInteger imageNum=0;imageNum<30;imageNum++)
{
NSString *pictureName = [[NSString alloc]initWithFormat:@"%d.png",imageNum];
UIImage *image = [UIImage imageNamed:pictureName];
[images addObject:image];
}
But, even though it compiles ok without any errors or warnings, the app crashes when trying to open.
Please, someone tell me what I am doing wrong and how I can fix it.
Thank you.
(also, can someone tell me if e.g. images[5] is the right way to access an element in the array?)