0

Just new to xcode. I'm trying to create a quiz app with several questions and answers stored in a plist file. So far the first question and answers are correctly displayed in a labels on the UIView. There is also a next button that displays when the correct answer is given. When the "Next" button is pressed the next question and answers should be loaded into the labels on the UIView.

Any idea what the code for this might be?

4

1 回答 1

0

我同意 hw731 关于这个问题的广泛性,但是......我最近一直在与 plists 合作,我很高兴根据我所做的分享一个建议。通常,我发现的是这样的:

    path = [[NSBundle mainBundle] pathForResource: @"questions" ofType: @"plist"];

    if ([fileManager fileExistsAtPath: path])
    {
        questionsArray = [[NSMutableArray alloc] initWithContentsOfFile: path];
    }

这会将您的 plist 变成一个数组,这将使您能够将您的想法从“如何从 plist 获取信息”转变为“如何遍历数组”。您可以通过它的数组索引轻松跟踪当前正在显示的问题,然后通过增加索引来检索下一个项目。

于 2014-01-22T16:44:13.567 回答