0
因为每个arrayWithObjects:
都添加了一个新问题(它是一个问答游戏),所以它被分解成几行。数组问题
但是,如何当它的NSLogged它只显示最后arrayWithObjects:
线。它是否覆盖别人或什么?
-(void)loadQuizFromArrays{ //ALL QUESTION DATA GOES HERE
/*theQuiz = [NSArray arrayWithObjects:@"question",@"possibleAnswer1",@"possibleAnswer2",@"possibleAnswer3",@"possibleAnswer4",@"correctAnswersNumber",nil];*/
theQuiz = [NSMutableArray arrayWithObjects:@"Which is NOT a StarWars movie?",@"Attack of the Jedi",@"A New Hope",@"The Phantom Menace",@"Attack of the Clones",@"1", nil];
theQuiz = [NSMutableArray arrayWithObjects:@"In what state is the majority of Yellow Stone National Park in?",@"Ohio",@"California",@"Wyoming",@"Nebraska",@"3",nil];
theQuiz = [NSMutableArray arrayWithObjects:@"In the US, what household pet is the most common?",@"Cats",@"Dogs",@"Hamsters",@"Komodo Dragons",@"2",nil];
theQuiz = [NSMutableArray arrayWithObjects:@"A plane is traveling 2675 miles every 5 hours. How many miles does the plane travel in 1 hour?",@"535",@"325",@"540",@"420",@"1",nil];
NSLog(@"%@",theQuiz);
}
我wasen't知道它可以覆盖它。这解释了很多。谢谢 只是检查它完美的作品! – user377419 2010-07-14 13:55:13
@ shorty876:代码一直给同一个变量分配一个新的数组。这相当于写入'number = 1;数字= 2;数字= 4;数字= 8;';在执行该代码之后,该变量保存分配给它的最后一个值。 – kiamlaluno 2010-07-14 14:10:33