Return to Snippet

Revision: 51603
at October 4, 2011 05:18 by ggrngg


Updated Code
//First, define how many images will be in your array
//Just change to adjust to your own number of images
#define IMAGE_COUNT 20


//create an array to hold the images

NSMutableArray *imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];

//build array of images, cycling through image names
int i;
for(i=1; i<IMAGE_COUNT; i++)
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"frame-%d.png", i]]];

//another short example:
for (int c=0;c<300;c++)
{
    NSString *imageName = [NSString stringWithFormat:@"name%d.png", c];
    [UIImage imageNamed: imageName];
}

Revision: 51602
at September 29, 2011 03:43 by ggrngg


Initial Code
//First, define how many images will be in your array
//Just change to adjust to your own number of images
#define IMAGE_COUNT 20


//create an array to hold the images

NSMutableArray *imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];

//build array of images, cycling through image names
int i;
for(i=1; i<IMAGE_COUNT; i++)
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"frame-%d.png", i]]];

Initial URL

                                

Initial Description
Rather than creating an array of images where you list each image individually this will loop through images that all have the filename "frame-X.png" where X is a number from 1 to 20.  So if you have a series of images "frame-1.png", "frame-2.png" this loop will create the array.  Good for creating an image-based animation.

Initial Title
Build Array of Images with NSMutableArray

Initial Tags
array, images, animation

Initial Language
Objective C