How to load all images with similar names

69 views Asked by At

I have several images in my xcasset, so i can load image with:

[UIImage imageNamed:@"face_icon_1"];

If my images names is like "face_icon_2", "face_icon_3" and etc., how do i found them all and without hardcode?

1

There are 1 answers

0
rounak On BEST ANSWER
UIImage *image;
NSInteger counter = 1;
do {
  image = [UIImage imageNamed:[NSString stringWithFormat:@"face_icon_%zd", counter++];
//add the image to an array
} while (image);