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