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 7793327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:27:07+00:00 2026-06-01T22:27:07+00:00

I am trying to create an iOS app which involves one main if statement

  • 0

I am trying to create an iOS app which involves one main if statement to check if a text box contains certain text. I would like to check for multiple instances of a certain word but I don’t want to do multiple if statements as this will dramatically slow down the performance of the app.

How can I check if a word matches that of a word in an NSArray, and if it does, return a NSString associated with that word in another text box?

  • 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-06-01T22:27:09+00:00Added an answer on June 1, 2026 at 10:27 pm

    You can create an NSDictionary of the words you are checking against mapped against the NSString you want returned when that word is entered:

    NSDictionary *words = [[NSDictionary alloc] initWithObjectsAndKeys:
        @"word1", @"result1",
        @"word2", @"result2",
        /*etc*/
        nil];
    
    NSString *wordFromTextBox = ...;
    NSString *result = [words objectForKey:keyword];
    if (result != nil)
    {
        // use result
    }
    else
    {
        // word wasn't something we expected
    }
    
    // Some time later
    [words release];
    

    EDIT: To iterate over the list so you can test if the keywords are contained in the textbox, you can do the following (assume words and wordFromTextBox are set-up as before):

    NSEnumerator *enumerator = [words keyEnumerator];
    while ((NSString *keyword = [enumerator nextObject]) != nil)
    {
        if ([wordFromTextBox rangeOfString:keyword].location != NSNotFound)
        {
            NSLog(@"The text box contains keyword '%@'", keyword);
            NSString *result = [words objectForKey:wordFromTextBox];
            // Use the result somehow
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to create a photo viewer like the Apple Photos app in iOS.
I am trying to create a jigsaw puzzle app for iOS. From my searches
I'm trying to create an iOS application which upon loading, will initially connect via
I am trying to create an intro animation for my iOS app and am
We're trying to make an iOS app that allows users to create geographical points
I was trying to add AMR-NB decoding support to an iOS app, which has
I'm trying to make an iOS app that allows the user to create an
I'm trying to create an UIImage test pattern for an iOS 5.1 device. The
I'm trying to create a card flipping animation on iOS, and I'm failing miserably.
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can

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.