简体   繁体   中英

What data structure should I use to store the results of a survey?

Xcode 5/iOS7 No Core Data.

I'm trying to do a survey for users and need some assistance on setting up the Data structure.

The survey is basically a Tree. Depending upon what the option user selects, next screen can different.

Here is the format:

Scene 1: Question 1 
Answer choices for Question 1:

Answer 1A  //This option will take them to scene 2A -- all the answers will take them to --> 3A -- then all the options in 3A will take them to 4A and the survey will end

Answer 1B  //This option will take them to scene 2B -- all the answers will take them to 3B --> then all the options in 3B will take them to 4A and the survey will end

Answer 1C  //This option will take them to scene 2C -- all the answers will take them to 3C --> then all the options in 3C will take them to  4A and the survey will end

Answer 1D  //This option will take them to scene 4A and the survey will end

Answer 1E  //This option will take them to scene 5A and the survey will end

Hopefully the above make sense.

So my question is, what's the best way to keep track of what options the user selected, especially when the user clicks 'Back'.

My thought is doing an Array for each scene where the question in each array is [NSArray objectAtIndex:0] answer choices will be [NSArray objectAtIndex:1] , [2] , [x]

But I'm not sure how to keep track of what Scene to call next, and which Scenes the User was prompted and the answer choices that were selected.

Has anybody dealt with something like this? Any guidance on data structure would be appreciated!

我认为您可以将这些选项映射到某些特殊字符,例如“ X”(后退),“ y”(前进),也可以使用这些字符的Ascii值(根据每个字符的Ascii值确定条件)进一步分配数字,从而实现搜索或移至树的特定分支。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM