简体   繁体   中英

Best way to store Trivia game data?

I'm creating an iOS trivia game that will have between 1,000 - 10,000 questions in it. Each question will have only two possible answers, so the amount of data per question will be very small.

I'm wondering if I should use Core Data to store the questions or if I can use a large dictionary that I populate when the app loads up?

Would either of those choices work or is there a better solution I haven't considered?

The 'best' way to store these questions depends heavily on your internal data structures, memory usage and source data structures.

How do you receive the questions? If they are an XML then you might like to preserve that structure and implement an XML parser. If Excel format, export to CSV and read from that. JSON: load into an NSDictionary.

If you want to add these into Core Data or sqlite and the source questions are in a different format, you will have to write a parser and importer. Then, if you update questions you will have to create a merge policy etc.

Personally, if you can keep the original format of the data without complicating code/exceeding memory I would keep it simple and go for that - that way, you can replace the source file and it will just work.

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