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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:25:44+00:00 2026-05-12T07:25:44+00:00

Much of my code is based off of Apple’s TableSearch example, however my app

  • 0

Much of my code is based off of Apple’s TableSearch example, however my app contains 35,000 cells that need to be searched rather than the few in the example. There isn’t much documentation online about UISearchDisplayController since it is relatively new. The code I am using is as follows:

- (void)filterContentForSearchText:(NSString*)searchText {
/*
 Update the filtered array based on the search text and scope.
 */

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

/*
 Search the main list for products whose type matches the scope (if selected) and whose name matches searchText; add items that match to the filtered array.
 */
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
for (Entry *entry in appDelegate.entries)
{
    if (appDelegate.searchEnglish == NO) {
        NSComparisonResult result = [entry.gurmukhiEntry compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
        if (result == NSOrderedSame)
        {
            [self.filteredListContent addObject:entry];
        }
    }
    else {
        NSRange range = [entry.englishEntry rangeOfString:searchText options:NSCaseInsensitiveSearch];
        if(range.location != NSNotFound)
        {
            [self.filteredListContent addObject:entry];
        }

    }
}}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self filterContentForSearchText:searchString];
[self.view bringSubviewToFront:keyboardView];

// Return YES to cause the search result table view to be reloaded.
return YES;}

My problem is that there is a bit of a delay after each button is pressed on the keyboard. This becomes a usability issue because the user has to wait after typing in each character as the App searches through the array for matching results. How can this code be adjusted so that the user can continually type without any delays. In this case, it is ok for a delay in the time it takes for the data to reload, but it should not hold up the keyboard in typing.

  • 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-12T07:25:44+00:00Added an answer on May 12, 2026 at 7:25 am

    Update:

    One way to acccomplish searchching while typing without “locking up” the UI, is to use threads.

    So you can call the the method that performs the sorting with this method:

    - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg
    

    Which will keep it out of the main thread, allowing the UI update.

    You will have to create and drain your own Autorealease pool on the background thread.

    However, when you want to update the table you will have to message back to the main thread (all UI updates MUST be on the main thread):

    - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait
    

    You could also get a little more control by using NSOperation/NSOperationQueue Or NSThread.

    Note that implementing threads is fraught with peril. You will have to make sure your code is thread-safe and you may get unpredictable results.

    Also, here are other stackoverflow answers that may help:

    Using NSThreads in Cocoa?

    Where can I find a good tutorial on iPhone/Objective-C multithreading?


    Original answer:

    Don’t perform the search until the user presses the “search” button.

    There is a delegate method you can implement to catch the pressing of the search button:

    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd much rather code an app using pure C api such as OpenGL, rather
I've heard powershell 2.0 CTP has modules, but I can't find much example code
Pretty much what the title says really. We have some code that is .NET
How much code kludge could you remove using the resharper 4? I want to
How much code documentation in your .NET source is too much? Some background: I
I want to be able to get an estimate of how much code &
I want to be able to get an estimate of how much code &
I'm trying to do the following without too much special case code to deal
I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code
Here's the code. Not much to it. <?php include("Spreadsheet/Excel/Writer.php"); $xls = new Spreadsheet_Excel_Writer(); $sheet

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.