For a Quiz game I would like to store the questions in a database containing 7 columns for the Primary key, Question, 4 answers, and the correct answer then run a random method that would pick on of the questions and populate several text fields with the data.
I would then store the value for the "correct answer" column in a variable for a if statement called later on when the user selects an answer.
I have attempted so many tutorials involving SQLite databases that I am very unclear how to do the following:
Connect my xcode project to the database (a read-only database stored in the resources folder)
Load the database into an object (or load each row at run time at each question to save memory?)
Make a method that randomly selects a row, then p开发者_运维问答opulates text fields with the data and stores the correct answer column into a variable.
I have been banging my head on my desk for several weeks now, so ANY help would be GREATLY appreciated!
Thanks guys!
iPhone Programming Tutorial – Creating a ToDo List Using SQLite Part 1
iPhone SDK Tutorial: Reading data from a SQLite Database
Selecting a Random Row in SQLite
SELECT * FROM table ORDER BY RANDOM() LIMIT 1;
And here is Core Data and How to select a random row if you want to give that a try
精彩评论