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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:53:17+00:00 2026-05-30T00:53:17+00:00

I have a UISearchDisplayController that I am currently regretting implementing. The problem is that

  • 0

I have a UISearchDisplayController that I am currently regretting implementing. The problem is that my search controller accesses a web service and then updates a UITableView by calling [tableView reloadData]. Every time a user enters a key, it searches. I’ve been able to partially relieve the symptoms by requiring at least three characters before calling the ASIHTTPRequest but there must be a better way. Basically I want the UISearchDisplayController to wait for N seconds OR for the user to press “Search” before searching. Here’s what I have now:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {

    if (searchString.length > 2) {

        ASIHTTPRequest *request = [IKRequestBuilder requestForIKDogFoodWithQueryString:searchString];
        [request setDelegate:self];
        [request startAsynchronous];
    }   

    return NO;
}

#pragma mark - ASI HTTP Request

- (void)requestStarted:(ASIHTTPRequest *)request {
    //show activity view over table view
}

- (void)requestFinished:(ASIHTTPRequest *)request {
    NSString *response = [request responseString];
    self.dogFoods = [IKJsonFactory buildIKDogFoodArrayWithJSON:response];
    [self.searchDisplayController.searchResultsTableView reloadData];
}
  • 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-30T00:53:20+00:00Added an answer on May 30, 2026 at 12:53 am

    Add an NSTimer as a property on your search delegate.

    In the shouldReloadTableForSearchString:(NSString *)searchString delegate method, instead of sending the request straight away, instead check if you have a timer already, if so cancel it, then start a new timer.

    In the timer’s target method, kick off the search.

    This will mean that while they are typing you will keep recreating the timer. When they stop typing the last incarnation of the timer will fire in n seconds. Then you just need to also add the manual kicking off of the search when they press the button. (you could also add a boolean to check if the search has already been started).

    i.e. in your delegates interface

    NSTimer *searchTimer;
    
    @property (nonatomic, retain) NSTimer *searchTimer;
    

    Then in your implementation of the shouldReloadTableForSearchString, instead of firing off the web request, do this:

    if (self.searchTimer) {
        [self.searchTimer invalidate];
        self.searchTimer = nil;
    }
    self.searchTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(searchTimerPopped:) userInfo:nil repeats:FALSE];
    

    Then in your timer target

    -(void) searchTimerPopped:(NSTimer *)sTimer {
        // code to fire off the asynchronous web call to do the search
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

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 .
Have a n-tire web application and search often times out after 30 secs. How
I have a UISearchDisplayController that displays some cells after a user has searched. After
I have implemented a SearchBar using a UISearchDisplayController and a UITableView to display the
I have a UISearchDisplayController that shows the cancel button. I would like to call
I have a UITableViewController with a UISearchDisplayController (and UISearchBar ) that is contained in
I have a UITable that has a UISearchDisplayController . The UITable is less than
I have a UISearchDisplayController that I've added in IB. How can I make its
I have a problem: I am programming an app that is using a searchBar

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.