我有一个字典数组存储在带有键和字符串的 plist 中,它们是我的测验应用程序的问题和答案。我在屏幕上放了一个随机问题,但我想在屏幕上也以随机顺序放置问题的答案。我怎样才能做到这一点?
引用问题的方式如下:
-(void)displayQuestion: (NSDictionary *) Question
{
[questionLabel setText:[Question objectForKey:@"Question"]];
[answer1 setText:[Question objectForKey:@"Answer1"]];
[answer2 setText:[Question objectForKey:@"Answer2"]];
[answer3 setText:[Question objectForKey:@"Answer3"]];
}
<dict>
<key>category</key>
<string>Elementary Pilot</string>
<key>Question</key>
<string>You are approaching a hang glider head-on and at approximately the same height. You should:</string>
<key>Answer1</key>
<string>Turn to your right?</string>
<key>Answer2</key>
<string>Turn to your left?</string>
<key>Answer3</key>
<string>Lose height rapidly?</string>
</dict>