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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:12:56+00:00 2026-06-06T23:12:56+00:00

I have a core data database and each row is shown in a table.

  • 0

I have a core data database and each row is shown in a table.

I have a search controller to enable the user to search by first or last name.

When i get results from ‘filteredArrayUsingPredicate’ i reload the search controller table and all works fine. The table shows the filtered results.

When it comes to select a result, the results array is empty and subsequently crashes due to [array atIndex:index path.row] out of bounds. The array is empty making me think it has been released.

This code works perfectly on another view. i have tried re writing and clean and build and still happening- any ideas?

Below is my code

@property(nonatomic,retain) NSArray* cachedSearchResults;

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


    NSPredicate * predicate =  [NSPredicate predicateWithFormat:@"first_name contains[cd] %@ || last_name contains[cd] %@",searchText, searchText];
    self.cachedSearchResults = [[self.cachedResults filteredArrayUsingPredicate:predicate]retain];
;
    [searchController.searchResultsTableView reloadData];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

PupilManagedObject* selected = nil;
if(tableView == table){
    selected = [cachedResults objectAtIndex:indexPath.row];
}else{
    selected = [self.cachedSearchResults objectAtIndex:indexPath.row]; //array is empty at this point
}
}
  • 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-06T23:12:58+00:00Added an answer on June 6, 2026 at 11:12 pm

    I found the issue was the search controller was dismissed before i made use of the data in the array. odd but changing the order of my code worked

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

Sidebar

Related Questions

I have an Event database loaded into Core Data that has duplicate Event titles.
I have a Core Data database of about 500 objects. These objects are 'cards'
I have a Core Data database with latitude and longitude properties. Is there a
I have an iPhone app with a Core Data database containing a list of
I have a SQLite backed database of roughly 4000 rows, connected to Core Data.
I have a core data model, using the database store, that contains entities with
I have an entity (on Core Data ) called Contact , each contact has
I have a simple database with a Persons table UserId, Name,DOB The table contains
In my app i have to store Core Data Database and audio files, so
I have to use CoreData based database to store my data. At high-level my

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.