http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application
Here's what they have to say about a loop in the select routine:
A return value of SQLITE_ROW indicates that at least one match has been located. In this case the first matching result data is extracted, assigned to NSString objects and displayed in the appropriate text fields. As an alternative, a while loop could have been constructed to display all matching results
Cool. I'm feeling just a little bit crazy today. Let's see if we can print the whole database ;)
Ok, it's just a couple of small adjustments - dump the where clause, substitue a "while" for the "if", and get rid of that if's else statement. Let run it...
2011-08-31 16:28:14.461 JlptQuizApp[5602:207] select all, row found
2011-08-31 16:28:14.462 JlptQuizApp[5602:207] kanji: 会う, hiragana: あう, english: to meet
2011-08-31 16:28:14.462 JlptQuizApp[5602:207] select all, row found
2011-08-31 16:28:14.463 JlptQuizApp[5602:207] kanji: 青, hiragana: あお, english: blue
2011-08-31 16:28:14.463 JlptQuizApp[5602:207] select all, row found
2011-08-31 16:28:14.464 JlptQuizApp[5602:207] kanji: 青い, hiragana: あおい, english: blue
2011-08-31 16:28:14.464 JlptQuizApp[5602:207] select all, row found
2011-08-31 16:28:14.465 JlptQuizApp[5602:207] kanji: 赤, hiragana: あか, english: red
2011-08-31 16:28:14.465 JlptQuizApp[5602:207] select all, row found
2011-08-31 16:28:14.466 JlptQuizApp[5602:207] kanji: 赤い, hiragana: あかい, english: red
2011-08-31 16:28:14.582 JlptQuizApp[5602:207] select all, row found
2
....
Yup. It work. Ok - in the next post, we'll *really* bring the data into the app, instead of just printing it.
No comments:
Post a Comment