As chown33 mentioned, the following can only be a guess based on the little we know. A few thoughts popped into my head and I thought I'd share them.
So, i'm making a simple app that contains 9 views, each one with 3 question...
About the getAnswer, all my scenes (storyboard) are identified by a number (int).
It sounds to me that you are creating independent screens (scenes) for each question (or collection of 3). I think you should create only one such screen that is capable of handling all of the questions and answers. Consider what you would do if there were 10,000 questions. Certainly you could create a reusable screen that keeps track of those +numbers rather than creating a bunch of similar screens that you pass values forward to.
As for the model and using plists, that is fine for a small list but would likely be a burden with thousands of entries. Use of a singleton as the interface to your questions and answers seems OK. In the future this would allow you to change the underlying data container from a plist to some other possibility like a local database or an web source, but keep the client interface methods the same.
Here is one idea...
First, I didn't understand why you are writing back to the questions plist file. That would seem to be a different mode of test app. So the following
assumes only the test mode in a Q&A scenario. It looks like there may be more to your app, but the idea I present may be useful for you.
For the plist, use a dictionary for each question and make the key a sequential number with no gaps. For the questions and answers, the dictionary value, a simple ordered array would be workable. The first entry would be the question, the second entry the correct answer, and any followup entries would be incorrect answers. I'm assuming this is a multiple choice test.
Your singleton would handle the initial load of the plist (or other future source), fetching a random dictionary entry, a comparison method for the chosen question, and fetch for the correct answer. The three unique methods might look like this;
Code:
- (NSDictionary *) fetchQuestion; // Internally chooses a random dictionary entry and returns it, or a copy (see below) preferably.
- (BOOL) compareAnswer: (NSString *) answer forKey: (NSNumber *) key;
- (NSString *) answerForKey: (NSNumber *) key;
Your view controller would need to randomize the order of the multiple choice answers for display, otherwise the correct answer would always be answer 1. If you were to use the compareAnswer method above, you could have your singleton reorder the answers in a copy of the dictionary. You could do that because then there is no reason for the view controller to know the correct answer in the dictionary in this scenario.
One weakness of the plist key is that if you skip a number during creation, your randomized selection would be broken. To fix this problem, it would be prudent to implement a solution to avoid that. I think a simple array of all of the keys would be workable. You'd pick the key from that list via your random number based on the array count.
By using a dictionary and key, you don't have to perform that looping. Also, I see you were loading your question multiple times but you wouldn't need to do that time consuming operation more than once if using a singleton because you would load it during initialization.