If you are loading 4.5mb of stuff into your application, it will crash, because iPhone applications can only use about 2mb of heap space before getting out of memory errors. These problems don't show up in the simulator because it has all your computer's memory at its disposal.
A sqlite3 database will probably work because you have a relatively simple application, but it will chew up a lot of memory and not give it back unless you're very careful. For each query you use, create a query handle (sqlite3_stmt) with the prepare API function, and save it into a global variable. Then reset that query when you are done, and re-run step when you want to run it again. This works but still seems to use up much more memory than is seemly. Creating ad hoc queries using sprintf() guarantees that your application will run out of memory and crash.
My iTrivia application (which you can buy from the app store starting today- hurrah!) works that way.
For a dictionary, I might recommend a simpler solution, as long as the number of words is not that high. Load the words and a record ID number into an array of objects. Then make the definitions files in your app bundle that are named after the ID number. For instance, record ID 10 would be 10.html .
This will give you blazing fast searches, since the words are in memory, and quick loads of the definitions into the web view because web views are designed to be used that way.
While developing my HauntFinder application (not yet submitted), I discovered that in a situation like this incremental search works great - that is, instead of waiting for someone to press the search button, take each character and have it search right away. So you type "d" and you get "dog", "domestic" and "diddle"; then type "o" and get "dog" and "domestic" and "m" and get only "domestic". It's actually quite surprising how few characters you need to zero in on the word you want.
This probably seems like a slightly bizarre way to work, since if you're like me you're spoiled by easy access to SQL data from other programming environments, but I can tell you that it will work, and look great to your end user.
Good luck with your application!
Hope that helps.
D
|