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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:27:47+00:00 2026-05-26T12:27:47+00:00

I am developing an iphone app where users input a few words and I

  • 0

I am developing an iphone app where users input a few words and I then need to look them up (if they exist basically) in a local hard coded long array of words (my case is more complex to explain, but lets say a user is entering 5 names of cities and I need to look up my array of cities and let him know which onces exist).

What would be the best way to go about this problem? especially since some of the names may be found in a sentence format (for example, someone can enter: “the city of paris”, but I have “Paris”, so its still good).

Is there any good 3rd part lib for that maybe? I can definitely try to do that manually, but I am sure there are some better solutions.

Thanks.

  • 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-26T12:27:48+00:00Added an answer on May 26, 2026 at 12:27 pm

    I’d use NSPredicate:

    NSString *searchText = @"paris";  //user's input 
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self LIKE[c] %@", searchText]; 
    NSArray *results = [yourHardcodedArrayOfCities filteredArrayUsingPredicate:predicate];
    

    This will fill *results with any matching results from your main array. The [c] in the predicate specifies case insensitivity, so Paris will match paris or pArIs.

    Edited to add

    Instead of using LIKE in the predicate (as shown in my original answer), it is easier to use CONTAINS to find matches if your search text is a sentence. So, you could use:

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self CONTAINS[c] %@", searchText];
    

    Same result, but a bit easier. This way, if the search string is “New York City” or “City of New York” it will still match on your hardcoded entry of “New York”.

    Here is an Apple doc on using predicates which you might find useful: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html

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

Sidebar

Related Questions

We are developing an iPhone app where we need to allow users to search
I've been developing an iPhone app for the last few months. Recently I wanted
I'm developing an iPhone app and doing ad-hoc distribution for beta testing. My users
I'm developing a iPhone app and need to send it to my client. In
We are part way through developing a professional app, the users login using iPhone
I'm developing a simple iPhone app where users register, and sign in with their
I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to
I've been developing an iPhone app that uses a UIToolbar (in the context of
Im developoing an app for the iPhone where users can chat using their facebook
I'm developing an iPhone app and have a question about memory management. Let's say

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.