如何创建多个问题? [英] How to Create a Multiple Question?

查看:137
本文介绍了如何创建多个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从plist检索6个问题,并从plist本身检查答案是否正确



我将使用QR码扫描器api扫描为了回答,api将隐藏到一个字符串并从plist读取,以检查如果答案是否正确...是否有任何教程或引用我看看@ ??



在我的plist中有:
question〜具有以下字符串的字典:



NumberOfOption〜定义如果问题是多项选择或QR代码问题
问题〜问题本身
答案〜答案本身
选项1〜4〜如果它是多项选择问题



非常感谢。



干杯



Desmond


使用以下代码读取数据到字典数组中(假设您的plist在您的主包中)

  // plist的路径(在应用程序包中)
NSString * path = [[NSBundle mainBundle] pathForResource:
@questionArrayofType: @plist];

//从plist构建数组
NSMutableArray * qArray = [[NSMutableArray alloc] initWithContentsOfFile:path];

您可以重复以下问题:

  //迭代问题
for(NSDictionary * dic in qArray)
{
//从dic对象读取'NumberOfOption'这里。
}


I need to retrieve 6 questions from a plist and check the answer if is correct from the plist itself??

i will use a QR code scanner api to scan for answer, the api will covert to a string and read from the plist to check if the answer is correct... is there any tutorial or references for me to look @ ??

In my plist there is: question ~ Dictionary with the following strings:

NumberOfOption ~ which define if the question is a multiple choice or a QR code question Question ~ question itself Answer ~ Answer itself Option 1 ~ 4 ~ if it is a multiple choice question

Thanks in advance for answering my questions, i appreciated it

cheers

Desmond

解决方案

Use the following code to read data into a array of Dictionaries (assuming your plist is in your main bundle)

// Path to the plist (in the application bundle)
NSString *path = [[NSBundle mainBundle] pathForResource:
    @"questionArray" ofType:@"plist"];

// Build the array from the plist  
NSMutableArray *qArray = [[NSMutableArray alloc] initWithContentsOfFile:path];

you can then iterate over your questions like:

// iterate questions
for (NSDictionary *dic in qArray)
{
    //perform your reading of 'NumberOfOption' etc from dic object here. 
}

这篇关于如何创建多个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
移动开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆