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?