开发者

Using SQLite database for Quiz game

开发者 https://www.devze.com 2023-02-20 18:50 出处:网络
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 t

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:

  1. Connect my xcode project to the database (a read-only database stored in the resources folder)

  2. Load the database into an object (or load each row at run time at each question to save memory?)

  3. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号