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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:49:37+00:00 2026-06-08T22:49:37+00:00

I have a UISearchDisplay Controller setup, and it is working to filter values, but

  • 0

I have a UISearchDisplay Controller setup, and it is working to filter values, but I was wondering if someone could help me with a little bit more advanced way of filtering the results.

Say my array was:
{ American example, Eric, Different-Eric }

If the user searched “Eri”, the results should be
{ Eric, Different-Eric }
because is should only return results where a word starts with the substring, not if its in the center of a word (American).

It should also check if ‘-‘ could be a ‘ ‘, and visaversa. So the substring ‘Different-Eri’ would also search the substring ‘Different Eri’, and in reverse too.

If you need any more clarification, I’d be happy to answer. I was just wondering if there was a good way to go about this.

Current code:

NSPredicate *resultPredicate = [NSPredicate 
                                    predicateWithFormat:@"SELF.comname contains[cd] %@",
                                    searchText];

    searchResults = [[birdsArray filteredArrayUsingPredicate:resultPredicate] mutableCopy];
  • 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-08T22:49:38+00:00Added an answer on June 8, 2026 at 10:49 pm

    I actually solved this by making some changes to my Custom Object and the search predicate. A lot simpler of a solution than I was previously thinking.

    In my Custom Object I made 2 properties, and had the Getters method return a ‘first name’ and ‘last name’ respectively, which basically broke the full string into the first word and last word, using ‘ ‘ or ‘-‘ as word deliminators.

    The my search predicate simply became:

    NSPredicate *spacePredicate = [NSPredicate 
                                       predicateWithFormat:@"SELF.comname BEGINSWITH[cd] %@ OR SELF.lastname BEGINSWITH[cd] %@",
                                       searchText, searchText];
    
        searchResults = [[birdsArray filteredArrayUsingPredicate:spacePredicate] mutableCopy];
    

    I used ‘BEGINSWITH’ instead of contains to make sure the start of the word matched the substring.

    The end :), hope it helps someone.

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

Sidebar

Related Questions

I have a IUSearchBar with an UISearchDisplayController, and everything is working well: When I
have written this little class, which generates a UUID every time an object of
Have done quite a bit of searching for a guide (of any substance) for
I have a UISearchBar and UISearchDisplayController, everything works great but my scope selector displays
I have a three20 controller that is using the new sdk3 UISearchDisplayController. I also
I have a UITableView in a controller that is nested under a UITabBar .
I have an UITabBar controller managing several controllers (using SDK 3.0). One of these
I am using search display controller in my code for searching. But it is
Have one Doubt In MVC Architecture we can able to pass data from Controller
I have some code, but I can't see how I can optimize it. Allthough

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.