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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:16:49+00:00 2026-06-05T04:16:49+00:00

I am presenting a table view in modal view controller created with the following

  • 0

I am presenting a table view in modal view controller created with the following code (http://stackoverflow.com/questions/4471289/how-to-filter-nsfetchedresultscontroller-coredata-with-uisearchdisplaycontroll) so I can use Core Data, NSFetchedResults and a UISearchbar. I finally have everything working well on the table view/search/detail view end, but I just discovered a showstopper I can’t seem to figure out.

When I dismiss the tableview using:

  - (IBAction)doneButtonPressed:(id)sender {[self dismissModalViewControllerAnimated:YES];}

the modal view dismisses, the main view loads, and then the app crashes. It’s getting far enough that I can call this nslog from the main view controller:

-(void) viewDidAppear:(BOOL)animated { NSLog(@"do I crash");}

I’m getting the bad access error here:

   int main(int argc, char *argv[]) 
   {
       @autoreleasepool {
         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));}}

I believe the issues may be arc related. The code template I used was not for arc, so I made the following changes:

    @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
    @property (nonatomic, retain, readonly) NSFetchedResultsController *fetchedResultsController;

to

    @property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
    @property (nonatomic, strong, readonly) NSFetchedResultsController *fetchedResultsController;

    @property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
    @property (nonatomic, retain) NSFetchedResultsController *searchFetchedResultsController;
    @property (nonatomic, retain) UISearchDisplayController *mySearchDisplayController;

to

    @property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
    @property (nonatomic, strong) NSFetchedResultsController *searchFetchedResultsController;
    @property (nonatomic, strong) UISearchDisplayController *mySearchDisplayController;

In addition, I removed the following from didreceivememorywarning:

   [fetchedResultsController_ release];
   [searchFetchedResultsController_ release];

and changed the following in – (NSFetchedResultsController *)fetchedResultsController

    return [[fetchedResultsController_ retain] autorelease];

to

    return fetchedResultsController;

and in – (NSFetchedResultsController *)searchFetchedResultsController

    return [[searchFetchedResultsController_ retain] autorelease];

to

    return searchFetchedResultsController;

I am completely stumped. Any assistance would be greatly appreciated!

  • 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-05T04:16:51+00:00Added an answer on June 5, 2026 at 4:16 am

    Well, problem solved. I can’t imagine I’m the first or last to have this issue, so in case you are having similar difficulties….

    After scouring the search code (I figured it had to have something to do with that, since if I searched before I closed the modal view, it wouldn’t crash), I still couldn’t find anything wrong.

    I realized, however, that I was creating both my searchBar and searchDisplayDelegate programmatically. On a whim, I decided to create the searchBar and displayDelegate in storyboard and then link them up. Once they were added, I commented out from loadView:

    //  UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 44.0)];
    //   self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    

    In addition, adding them in storyboard autocreated the following in viewDidUnload:

    [self setSearchBar:nil];
    [self setMySearchDisplayController:nil];
    

    Viola! No more crash… I think it was simply the mySearchDisplayController not unloading properly. Hope that helps others!

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

Sidebar

Related Questions

I am presenting a modal view controller like this from a table view (ignore
I'm getting a white screen after presenting a modal view controller. This is how
I have a modal view controller that I am presenting on iPad via: vc.modalPresentationStyle
I am presenting table view contents using NSFetchedResultsController which has a predicate: [NSPredicate predicateWithFormat:@visible
I have standard view controller acting as the delegate for a modal view controller
I created the following table for user to user subscriptions. CREATE TABLE IF NOT
I am trying to push in a new view controller with the code: [self.navigationController
We have a modal view that contains a Table view that contains UITableViewCells used
So I am presenting a full screen modal view when the user selects an
I have the following code but it keeps presenting errors. The first part of

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.