I am creating a game and have gotten to the point where I have the strings to look-up and see if they are indeed words defined in a words.txt file i want to import.
I know little about file IO in objective C/IOS, and a search has led me to something to do with sqlite and Lucene.
What is the best approach to a simple dictionary lookup to confirm a string is an actual dictionary word from words.txt?
This does not have anything to do with sqlite, unless you keep your file in the sqlite database, which you didn’t mention. The fastest way to do what you desire would be this:
Load the file to memory (unless this is a huge file which you don’t want to load at once, in this case use NSFileHandle):
Transfer the words to a collection, say an instance of NSArray for example. We assume the words are separated by a coma in the file:
Check if your word is in the array:
I assume that you want to avoid the possible problems with compound words, this is why step 2 and 3 is necessary. If you don’t have too many words in you file and you feel lucky, you can simply use rangeOfString method and skip step 2 and 3.