I have created two UIImageViews in my code:
UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(150, 60, 180, 180)];
UIImageView *result = [[UIImageView alloc]initWithFrame:CGRectMake(150, 60, 180, 180)];
[self.view addSubview:background];
[self.view addSubview:result];
[self.view insertSubview:result aboveSubview:background];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[background setImage:[UIImage imageNamed:[defaults objectForKey:@"colour"]]];
When you press a button, this code is executed:
- (IBAction)oneToSix {
int rNumber = (arc4random() % 6) + 1;
[result setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d", rNumber, @".png"]]];
}
but the image doesn’t change.
Also, I am getting these errors:

You are redeclaring variables in the method scope that were already defined at the class scope. Remove the
UIImageView *part from your initialization.Note: it’s doing nothing when you change image, because in ObjectiveC, a method call to nil (uninitialized instance member) is valid, and produces no visible result.