0

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?

Zaporozhchenko Oleksandr
  • 4,660
  • 3
  • 26
  • 48
  • What do you mean exactly by "finding them all"? Do you know beforehand the range of numbers or you want to load images starting with 1, for example, up to the max available number? – Alladinian Jun 18 '15 at 08:29
  • Find all images, that begin with "face_icon_", or all with "face_", so i would know how many images in my xcasset – Zaporozhchenko Oleksandr Jun 18 '15 at 08:39

1 Answers1

0
UIImage *image;
NSInteger counter = 1;
do {
  image = [UIImage imageNamed:[NSString stringWithFormat:@"face_icon_%zd", counter++];
//add the image to an array
} while (image);
rounak
  • 9,217
  • 3
  • 42
  • 59