so im trying to make a rock paper scissors app activated by either a button or the accelerometer by first doing a short animation which cycles through the three, then display a random image (1 of the 3) at the end of the animation. The animation itself works perfectly fine, but after it finishes the random image does not show.
UIImageView *image;
int x = arc4random() % 3 + 1;
NSString *imageName = [NSString stringWithFormat:@"image%d.jpg", x];
UIImage *img = [UIImage imageNamed:imageName];
It looks like you’re not initializing your
UIImageView. Also, for the random image, I recommend this code: (it’s more flexible)Don’t forget to release
imageonce you’re done with it.