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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:24:33+00:00 2026-06-07T01:24:33+00:00

I have a search bar added in the user interface. The Searchbar is already

  • 0

I have a search bar added in the user interface. The Searchbar is already set, and works, but I can’t figure out how to make it search content in the UITableView. Can I just remove the items that do not start with the characters typed in the search bar??

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
if (searchBar.text.length < 1) {
    return;
}
else {
    // Do search stuff here



}}

This code works, the else function is called. But I don’t know how to do it. I don’t want to create a whole new array just for that.

  • 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-07T01:24:35+00:00Added an answer on June 7, 2026 at 1:24 am

    I’ll do you one better. This example will search as the user types. If your data is quite massive, you may want to implement it in - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar like you originally planned. Unfortunately, you need a second array, but it’s easy to code around it in the table:

    -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
        if(searchText.length == 0)
        {
            isFiltered = FALSE;
        }
        else
        {
    
            isFiltered = true;
            if (filteredTableData == nil)
                filteredTableData = [[NSMutableArray alloc] init];
            else 
                [filteredTableData removeAllObjects];
    
            for (NSString* string in self.masterSiteList)
            {
                NSRange nameRange = [string rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];
                if(nameRange.location != NSNotFound)
                {
                    [filteredTableData addObject:string];
                }
            }
        }
        [self.tableView reloadData];
    }
    

    then update your delegate methods to show the data of the filteredTableData array instead of the regular array when the isFiltered var is set to YES.

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

Sidebar

Related Questions

I have search through the web to figure this out but no luck. I
In my app, I have a search bar which can search facebook user by
I have a search bar added to the navigation bar. When the user types
I have created a search bar for my website, the user may search a
I have a UI table view with a search bar and it works well
I have a Controller with a search bar at top, and when the user
I have implemented the search bar in my app and it´s working fine, but
I have a TabBar, NavBar, SearchBar with ScopeBar on my screen. I can search
I need to have a search bar control in my iPhone application, but I'd
I have implemented a UITableView with search bar (and search display) - all works

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.