Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-19-2009, 12:08 PM   #3 (permalink)
icelandic
Registered Member
 
Join Date: Jul 2009
Posts: 21
Default

Quote:
Originally Posted by smasher View Post
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 allocinitWithObjectsq0q1q2q3q4q5q6q7q8q9nil];
    
    
//pull imageviews from the array
    
UIImageView *gradedImage = [imageViews objectAtIndex:currentQuestionNumber];
    
gradedImage.image = [UIImage imageNamedimageLocation];
    
    
UIImageView *currrentImage = [imageViews objectAtIndex:currentQuestionNumber+1];
    
currrentImage.image = [UIImage imageNamedcurrentAnswerImage]; 
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?
icelandic is offline   Reply With Quote
 

» Advertisements
» Online Users: 349
16 members and 333 guests
ADY, BdR, dacapo, fiftysixty, F_Bryant, john love, kampftrinker, ligerligerliger, mer10, mizzytheboy, nobre84, syver, themathminister, TheWebWizz, XRumerTest
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,701
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:30 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.