Quote:
Originally Posted by scburns123
Hello All!
I am trying to develop a quiz application however I am not able to figure out how to tie all my ideas together under 1 app - if that makes any sense.
My objective is to create a quiz application that will have a picture and the user is to try and guess an answer from a set of 4 possible choices (i.e. close up picture of a nose of a dog and the users guesses whether its a cat's nose, cow's nose, dog's nose, or pig's nose).
So I am somewhat newer to iPhone programming and as an outline I was thinking I would have to do the following:
- Load the images in an array (understand this)
- Create 4 buttons for users to choose from (understand this)
- Have an image overlay the answer once a button was pressed (not sure how to do this)
- Generate images randomly, while having the correct answer follow (not sure on this either)
- Allow for next and previous function (understand this)
I have followed the quiz tutorial found on this thread ( http://www.iphonedevsdk.com/forum/ip...quiz-game.html) and learned quite a bit from it.
Could anyone provide any guidance on how to tie it all together? One of my biggest concerns is making the correct answer pop up when the quiz questions are generating randomly...
Any help would be appreciated, you all are great!
Thanks!
Shawn
|
Here's what I would do:
Design a dictionary structure that contains the different fields of a quiz question.
Define key/value pairs for the different things you need to store for each question:
an NSString with an image name
an array of possible answer strings
an integer correct answer index
Create an array to hold these question dictionaries, and create one question dictionary through code. Save the array with the one dictionary to disk using the NSArray method writeToFile:atomically: Make the suffix of the file be ".plist" (e.g. "questions.plist")
Save the questions.plist file to your apps's documents directory, and have the code log the full path to the console. Run the program on the simulator. Copy the path name into the clipboard, and then select that file in the finder and drag it into your project.
Once the questions.plist file is in your project, click on it to open it. Copy the dictionary object and then paste it, to create multiple entries in your questions array. Edit them to contain your questions. Save the plist changes.
Next, write code that loads the array into memory in your quiz view controller. When it's time to display a question, take the filename for the image, build a path to the file, and load it into your image view. Load the possible answer strings and install them into labels, or buttons titles, or however you want to display the choices. When the user makes a selection, compare it against the correct answer index.