nouf
nouf

Reputation: 31

array of UIImageView in objective c

I already had many UIImageViews.. I want to make an array of UIImageViews and assign every index with one of the UIImageViews above.. How can I do that with objective c??

Upvotes: 2

Views: 7299

Answers (2)

Blazej SLEBODA
Blazej SLEBODA

Reputation: 9915

NSMutableArray * imageViewsArray = [[NSMutableArray alloc] init];
[imageViewsArray addObject:imageView1];
[imageViewsArray addObject:imageView2];

UIImageView * imageView = [imageViewsArray objectAtIndex:0];

or UIImageView * imageView = imageViewsArray[0];

Upvotes: 2

Jamal Zafar
Jamal Zafar

Reputation: 2189

Declare a NSMutableArray

NSMutableArray * imagesArray = [[NSMutableArray alloc] init];

Simply add the Pointers to ImageViews in the Array E.g: imageView1, imageView2

[imagesArray addObjects: imageView1, imageView2, nil];

Don't forget to Release the array if you are not using ARC

Upvotes: 7

Related Questions