3. notice the retain message that gets passed to NSArray. This makes sure the objects are persistent in memory and available when "imageArray" is accessed in other functions.
4. without the retain message, the objects are released in viewDidLoad() and trying to access the array elements in another function will result in a crash.
I'm doing something similar but having a counter problem
Quote:
Originally Posted by paris
I have an NSArray that loads 30 images when the viewloads up.
I have a UIImageView that can display only one of these images at a given time.
The user clicks on a button to see the next image.
On each click I am doing this :
--
UIImage *img = [imageArray objectAtIndex:current_img_number];
[img_view setImage:img];
--
However the app crashes on every click.
Can anyone help me please?
Thanks,
Paris.
Paris - I am putting together a similar application. The counter I am using (analogous to your 'current_img_number' variable), is causing my program to crash whenever I increment it. Can you tell me how your are defining your counter and how you are incrementing it? When I initially set it, everything works. It's only after I come around a second time and increment it that the program crashes. I am getting a objc_msgSend error.