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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:35:58+00:00 2026-06-04T11:35:58+00:00

I have created a view with a tableview + searchbar. If searched for the

  • 0

I have created a view with a tableview + searchbar. If searched for the first word in a string it works perfectly! Unfortunately it does not work if searched for a different word in the string. So if I would have an search for the text: bal.

And I would have the following string to look through: green bal. it would not find anything.

I currently am comparing the searchbar text with the data with this code:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{

[self.filteredListContent removeAllObjects]; // First clear the filtered array.

for (Product *product in self.listContent)
{

    NSComparisonResult result = [product.name compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
    if (result == NSOrderedSame)
    {
        [self.filteredListContent product];
    }
}
NSMutableSet *tempSet = [NSMutableSet setWithArray:self.filteredListContent];
self.filteredListContent = [NSMutableArray arrayWithArray:[tempSet allObjects]];
}

How can I solve this issue?

Any help or suggestions would be appreciated!

  • 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-04T11:35:59+00:00Added an answer on June 4, 2026 at 11:35 am

    This code is looking for exact matches (insensitive to case as well as diacritics) using the compare:options:range: method in NSString:

    NSComparisonResult result = [product.name compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
    if (result == NSOrderedSame)
    {
        [self.filteredListContent product];
    }
    

    Given your problem description, you wish to determine a string is contained inside another string. Use the rangeOfString:options: method in NSString instead:

    NSRange range = [product.name rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];
    if (range.length > 0)
    {
        [self.filteredListContent product];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a TableView(Grouped Table View). And I can list the items in
I have a custom tableview cell created programmatically that consists of: a background view
I have created one navigation based application. In that first view show me the
I am new to iPhone development. I have created a table view in a
I have created View A and View B. My window has View A displayed
I have created navigaton view using Sencha touch 2. Navigation view has list component
I have created a View which prompts the user to input some records with
I have created a view in which there is a capture button. When i
if i have created a view model and have a partial form that is
I have a primary link accommodation, then i have created a view , called

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.