Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:44:13+00:00 2026-05-31T12:44:13+00:00

I am creating a game and have gotten to the point where I have

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:44:14+00:00Added an answer on May 31, 2026 at 12:44 pm

    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:

    1. 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):

      NSError* err;
      NSString* words = [NSString stringWithContentsOfFile:@"words.txt" encoding:NSUTF8StringEncoding error:&err];
      // check err!
      if (err) {
          // handle errors
      }
      
    2. 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:

      NSArray* wordsArray = [words componentsSeparatedByString:@","];
      
    3. Check if your word is in the array:

      NSString* wordWeLookFor = @"FooBar";
      NSUInteger index = [wordsArray indexOfObjectPassingTest:
               ^(id obj, NSUInteger idx, BOOL *stop) {
                  *stop = [(NSString*)obj isEqualToString:wordWeLookFor]
                  return *stop;
               }];
      if (index != NSNotFound) {
          // Found!
      } else {
          // Not found!
      }
      

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a word game where you have to spell the words in
I am creating a word game where you have to spell the words in
Hello I'm creating a game and I have a few ways to make trainers
I have started creating a game, and I added a second project, it's the
I have a question about lists in C++. I am creating a game, where
I am creating a small Yahtzee game and i have run into some regex
I'm creating an Android game and I encountered a problem. I have 2 threads:
I have been creating a peer to peer connection for a new game, that
I am creating a copy of the game Pig. I have got a text
My current class is planning on creating a basic networked game, but we have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.