Quote:
Originally Posted by smasher
It's possible, but it's not what you want here - you should use an array instead. You can add all of your object to an NSArray (or NSMutableArray if you need to modify the list) and access them like this:
Code:
//add imageViews to the array - do this once
NSArray *imageViews = [[NSArray alloc] initWithObjects: q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, nil];
//pull imageviews from the array
UIImageview *gradedImage = [imageViews objectAtIndex:currentQuestionNumber];
gradedImage.image = [imageViews imageNamed: imageLocation];
UIImageview *currrentImage = [myArray objectAtIndex:currentQuestionNumber+1];
currentImage.image = [UIImage imageNamed: currentAnswerImage];
|
I had to tweek the code a little but it's better than I got:
PHP Code:
//add imageViews to the array - do this once
NSArray *imageViews = [[NSArray alloc] initWithObjects: q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, nil];
//pull imageviews from the array
UIImageView *gradedImage = [imageViews objectAtIndex:currentQuestionNumber];
gradedImage.image = [UIImage imageNamed: imageLocation];
UIImageView *currrentImage = [imageViews objectAtIndex:currentQuestionNumber+1];
currrentImage.image = [UIImage imageNamed: currentAnswerImage];
I think I can solve this problem fully if I knew how to get the object id by only knowing the object name as a string. Is that possible?