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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-11-2010, 11:56 PM   #21 (permalink)
smasher
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

I gave an example of my array format before.

Code:
//in the future it'll be easy to load this format from a plist with
// NSArray initWithContentsOfFile

NSArray *quizArray = [[NSArray alloc] initWithObjects:

   [NSArray arrayWithObjects: @"The Daily Show blah blah blah?",@"1994",@"1996",@"1998",@"2001",@"2", nil],

   [NSArray arrayWithObjects: @"What were the blah blah blah?", @"R2D2 and C3PO", @"Steve and Earl", @"Han and Chewie", @"Mickey and Minnie", @"1", nil],

   [NSArray arrayWithObjects: @"Who was the blah blah blah?", @"Cliff", @"Sam", @"Woody", @"Norm", @"4", nil],

   [NSArray arrayWithObjects: @"Question number four? (correct D) ",@"A",@"B",@"C",@"D",@"4", nil],

   [NSArray arrayWithObjects: @"Question number five? (correct A) ",@"A",@"B",@"C",@"D",@"1", nil],

   nil];
Now you can pull an individual question by saying:
Code:
//pull 3rd question
NSArray *question = [quizArray objectAtIndex:2];
And you can get the parts of the question like so:
Code:
	// Set the question string, and set the buttons the the answers
	NSString *activeQuestion= [question objectAtIndex:0];
	
	answerOne.title = [question objectAtIndex:1];
	answerTwo.title = [question objectAtIndex:2];
	answerThree.title = [question objectAtIndex:3];
	answerFour.title = [question objectAtIndex:4];

	rightAnswer = [[question objectAtIndex:5] intValue];
	
	// Set theQuestion label to the active question
	theQuestion.text = activeQuestion;
Very pretty, right?
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,551
Threads: 94,078
Posts: 402,724
Top Poster: BrianSlick (7,990)
Welcome to our newest member, hongto24
Powered by vBadvanced CMPS v3.1.0

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