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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:01:13+00:00 2026-05-16T14:01:13+00:00

I am facing a problem in implementing the search functionality in Table Views… Here

  • 0

I am facing a problem in implementing the search functionality in Table Views… Here is the code i am implementing to search…

- (void) searchTableView {

NSString *searchText = searchBar.text;
NSMutableArray *searchArray = [[NSMutableArray alloc] init];

searchArray = [data boats];

for(Boat *boat in searchArray)
{
    NSRange titleResultsRange = [[boat boatName] rangeOfString:searchText options:NSCaseInsensitiveSearch];

    if (titleResultsRange.length > 0)
        [copyListOfItems addObject:boat];
}

[searchArray release];
searchArray = nil;

}

When the search bar starts getting edited, i call this…

- (void)searchBar:(UISearchBar *)theSearchBar textDidChange:(NSString *)searchText {

//Remove all objects first.
[copyListOfItems removeAllObjects];

if([searchText length] > 0) {

    [ovController.view removeFromSuperview];
    searching = YES;
    letUserSelectRow = YES;
    self.tableView.scrollEnabled = YES;
    [self searchTableView];
}
else {

    [self.tableView insertSubview:ovController.view aboveSubview:self.parentViewController.view];

    searching = NO;
    letUserSelectRow = NO;
    self.tableView.scrollEnabled = NO;
}

[self.tableView reloadData];

}

and i assign the value to table row using…

if(searching)
{
    Boat *copyboat = [copyListOfItems objectAtIndex:[indexPath row]];
    cell.textLabel.text = [copyboat boatName];
    NSLog(@"%@", [copyboat boatName]);
}
else {
    Boat *fullboat =[data.boats objectAtIndex:[indexPath row]];
    cell.textLabel.text =[fullboat boatName];       
}

But when i start typing the values in search bar, the app is crashing. I get different errors when i type different alphabets. I get errors like.
* Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[NSMutableArray objectAtIndex:]: index 6 beyond bounds [0 .. 5]’

or

* Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array’

Sometime its also showing EXEC_BAD_ACCESS also… I am screwed right now. Can anyone please tell me what the error exactly is…???

  • 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-16T14:01:14+00:00Added an answer on May 16, 2026 at 2:01 pm

    When you create the subset of boat names, do you change the value of what you return in numberOfRowsInSection? It looks like the table is reloading and trying to find data for 7 rows, but you now only have data for six. Something like:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    if (searching) {
        return [copyListOfItems count];
    } else {
        return [data count];
    }
    

    }

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

Sidebar

Related Questions

I am facing a problem when implementing some new code to an existing library.
I am implementing a small database(university Project) and i am facing the following problem.
Iam facing problem in understanding and converting a matlab code into opencv. I want
iam facing problem in passing array to view. this is my controller code.. function
I am facing a problem that I discovered while I was implementing a small
I am implementing a search functionality in a website I am building, which involves
I'm currently facing an interesting problem in my OSGi application. I'm implementing a configuration
I herewith a problem that i am facing while implementing PDF file in iPhone.
Facing problem with every fetch i want to make using EF Query model.Place here
I am facing problem while implementing https with webHttpBinding. I am getting below error

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.