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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:58:51+00:00 2026-05-14T18:58:51+00:00

I’m trying to add a Search bar to my UITableView. I followed this tutorial:

  • 0

I’m trying to add a Search bar to my UITableView. I followed this tutorial: http://clingingtoideas.blogspot.com/2010/02/uitableview-how-to-part-2-search.html.

I’m getting this error if I type a letter in the search box: Rooster(10787,0xa05ed4e0) malloc: *** error for object 0x3b5f160: double free
*** set a breakpoint in malloc_error_break to debug
.

This error occurs here:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
    [self handleSearchForTerm:searchString];

    return YES;
}

(on the second line)

- (void)handleSearchForTerm:(NSString *)searchTerm {
    [self setSavedSearchTerm:searchTerm];

    if ([self searchResults] == nil) {
        NSMutableArray *array = [[NSMutableArray alloc] init];
        [self setSearchResults:array];
        [array release];
    }

    //Empty the searchResults array
    [[self searchResults] removeAllObjects];

    //Check if the searchTerm doesn't equal zero...
    if ([[self savedSearchTerm] length] != 0) {
        //Search the whole tableList (datasource)
        for (NSString *currentString in tableList) {
            NSString *klasString = [[NSString alloc] init];
            NSInteger i = [[leerlingNaarKlasList objectAtIndex:[tableList indexOfObject:currentString]] integerValue];
            if(i != -1) {
                klasString = [klassenList objectAtIndex:(i - 1)];
            }

            //Check if the string matched or the klas (group of school)
            if ([currentString rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location != NSNotFound ||
                [klasString rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location != NSNotFound) {
                //Add to results
                [[self searchResults] addObject:currentString];

                //Save the klas (group of school). It has the same index as the result (lastname)
                NSString *strI = [[NSString alloc] initWithFormat:@"%i", i];
                [[self searchResultsLeerlingNaarKlas] addObject:strI];
                [strI release];
            }

            [klasString release];
        }
    }
}

Can someone help me out?

Regards,
Dodo

  • 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-14T18:58:52+00:00Added an answer on May 14, 2026 at 6:58 pm

    The double free error means you have released an object more than needed. Here the suspicious object is klasString.
    From your code:

    NSString *klasString = [[NSString alloc] init];
    ...
    if(i != -1) {
        klasString = [klassenList objectAtIndex:(i - 1)];
    }
    ...
    [klasString release];
    

    The assignment inside the if statement

    1. loses reference to the newly allocated NSString, introducing a memory leak
    2. makes the later release apply to the object from klassenList. When klassenList releases its elements, a double free error will occur.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.