码云账号不再使用社区账号进行二次身份验证的通知 详情
私信发送成功
检测到您已登录技术前沿网,是否 一键登录码云
Watch Star

码云极速下载 / gwquestionnaire

此项目是为了提升国内下载速度的镜像仓库,每日同步一次,原项目仓库地址为 https://github.com/wojczitsu/GWQuestionnaire。
GWQuestionnaire - easy questionnaires and surveys solution for iOS
克隆/下载
wojczitsu 最后提交于 2014-03-14 03:51 . README update
Loading...
README.md 3.97 KB

GWQuestionnaire - easy questionnaires and surveys solution for iOS


alt tag

How to use it

Creating survey/questionnaire:

NSMutableArray *questions = [NSMutableArray array];

NSDictionary *a1 = [NSDictionary dictionaryWithObjectsAndKeys:@"YES",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a2 = [NSDictionary dictionaryWithObjectsAndKeys:@"NO",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a3 = [NSDictionary dictionaryWithObjectsAndKeys:@"A",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a4 = [NSDictionary dictionaryWithObjectsAndKeys:@"B",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a5 = [NSDictionary dictionaryWithObjectsAndKeys:@"C",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a6 = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"text",     
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a7 = [NSDictionary dictionaryWithObjectsAndKeys:@"2",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a8 = [NSDictionary dictionaryWithObjectsAndKeys:@"3",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a9 = [NSDictionary dictionaryWithObjectsAndKeys:@"4",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];


// single choice question
GWQuestionnaireItem *item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Single choice question ?"
                                                    answers:[NSArray arrayWithObjects:a1,a2, nil]
                                                       type:GWQuestionnaireSingleChoice];
[questions addObject:item];

// multiple choice question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Multiple choice question ?"
                                      answers:[NSArray arrayWithObjects:a3,a4,a5, nil]
                                         type:GWQuestionnaireMultipleChoice];
[questions addObject:item];

// "Rate" question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Rate it:"
                                      answers:[NSArray arrayWithObjects:a6,a7,a8,a9, nil]
                                         type:GWQuestionnaireRateQuestion];
[questions addObject:item];

// "open" question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Type your answer:"
                                      answers:nil
                                         type:GWQuestionnaireOpenQuestion];
[questions addObject:item];

surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
[self.view addSubview:surveyController.view];

Getting results from it:

// NSLog answers
for(GWQuestionnaireItem *item in surveyController.surveyItems)
{
    NSLog(@"-----------------");
    NSLog(@"%@",item.question);
    NSLog(@"-----------------");
    if(item.type == GWQuestionnaireOpenQuestion)
        NSLog(@"Answer: %@", item.userAnswer);
    else
        for(NSDictionary *dict in item.answers)
        {
            NSLog(@"%d - %@",[[dict objectForKey:@"marked"]boolValue], [dict objectForKey:@"text"]);
        }
}

项目点评 (0)

你可以在登录后,对此项目发表评论

Float_left Icon_close