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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:29:57+00:00 2026-05-24T03:29:57+00:00

I am trying to implement the content serch in iPhone using UISearchBar my code

  • 0

I am trying to implement the content serch in iPhone using UISearchBar my code is as below.

- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText {
    if([tableData count])
        [tableData removeAllObjects];

    //dataArray contains array of strings
         //tableData should containg arrow of strings as a serch result

    NSRange range = {0, [searchText length]};

    for(int i=0; i<[dataArray count]; ++i)
    {
        NSString *name = [dataArray objectAtIndex:i];

        if([name compare:searchText options:NSCaseInsensitiveSearch range:range] == NSOrderedSame)
            [tableData addObject:[dataArray objectAtIndex:i]];
    }
    [theTableView reloadData];
}

I am taking dataArray as a source of strings and then I want to search some content in each strings and then I need to store those strings which contains the search text, in the tableData array.

Write now I am getting only those strings as a search result in the starting text is matching as if in the dataArray there are 3 objects 1. India, 2. China, 3. America and I am serching “in” then it should show India and China both but it showing only India because “In” is starting content of India.

Please suggest me how to achieve the required result.

  • 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-24T03:30:00+00:00Added an answer on May 24, 2026 at 3:30 am

    To seach anywhere in the string you need to check the whole string to see if the searchTest appears anywhere:

    NSRange titleResultsRange = [name rangeOfString:searchText options:NSCaseInsensitiveSearch];
    
    if (titleResultsRange.length > 0)
        [tableData addObject:name]; // or [tableData addObject:[dataArray objectAtIndex:i]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement file upload functionality in the iPhone app. Server code is
trying to implement a dialog-box style behaviour using a separate div section with all
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm using acts_as_taggable_on in a model, and am trying to implement the auto_complete plugin.
I am trying to implement content flow in my zf application. And while loading
I'm trying to implement zclip to copy input's content into clipboard. There is 20
I am trying to implement a content formatting feature in my website - that
i am creating a web project using JSP, and is trying to implement a
While in search of trying to implement unique key validations for my db using
I'm new to Drupal (v6) and PHP, and I'm trying to implement some content

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.