我想制作一个问题应用程序,它显示我制作的 plist 中的一个随机问题。这就是函数(目前只有 7 个问题)。
我的函数给出了一个随机问题,但它总是以相同的问题开始,并且可以重复一个问题。我需要您的帮助来随机生成问题且不重复。
currentQuestion=rand()%7;
NSDictionary *nextQuestion = [self.questions objectAtIndex:currentQuestion];
self.answer = [nextQuestion objectForKey:@"questionAnswer"];
self.qlabel.text = [nextQuestion objectForKey:@"questionTitle"];
self.lanswer1.text = [nextQuestion objectForKey:@"A"];
self.lanswer2.text = [nextQuestion objectForKey:@"B"];
self.lanswer3.text = [nextQuestion objectForKey:@"C"];
self.lanswer4.text = [nextQuestion objectForKey:@"D"];