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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:38:09+00:00 2026-05-17T01:38:09+00:00

I have a UITabBarController. One of the tab shows application bookmarks, these bookmarks are

  • 0

I have a UITabBarController. One of the tab shows application “bookmarks”, these bookmarks are basicly search types saved to a Core Data (SQLLite) database.

When I load my application, go to the bookmark view (bookmarksViewController), it loads a function in my appDelegate (getBookmarks) and shows the result in an table. This works perfect, can switch between views, preform searches in other views switch back. No problem. It load the content every time.
BUT… when I load a search view and add a new bookmark, and then switch back to the bookmark view it dies with the error message “EXC_BAD_ACCESS“.
I have no idea why and how I can solve this.

This is my code:
bookmarksViewController.m

[...]
- (void)viewDidLoad {
    [super viewDidLoad];

 theBookmarks = nil;

    // Set up the edit and add buttons.
    self.navigationItem.rightBarButtonItem = self.editButtonItem;

 [self setTitle:NSLocalizedString(@"Bookmarks", @"bookmarksViewController")];
}

- (void)viewWillAppear:(BOOL)animated { 
 if (theBookmarks != nil)
 {
  NSLog(@"Release it!");
  [theBookmarks release];
 }

 NSLog(@"Appear 1");

 stationenAppDelegate *stationen = (stationenAppDelegate *)[[UIApplication sharedApplication]delegate];

 NSLog(@"Appear 1 - stage 2");

 theBookmarks = [[stationen getBookmarks] retain];

 NSLog(@"Appear 2");

    [super viewWillAppear:animated];
}
[...]

myAppDelegate.m

[...]
/**
 * Bookmarks
 *
 * Type definition
 * 1: Station search
 * 2: Train search
 * 3: Interuption search
 */

- (NSMutableArray*)getBookmarks
{
 NSLog(@"check 1");

 NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

 NSEntityDescription *entity = [NSEntityDescription entityForName:@"bookmarks" 
             inManagedObjectContext:self.managedObjectContext];
 [fetchRequest setEntity:entity];

 NSLog(@"check 2");

 NSError *error;
 NSArray *items = [[self.managedObjectContext
        executeFetchRequest:fetchRequest error:&error] retain];
 NSMutableArray *returnArray = [[[NSMutableArray alloc] initWithArray:items] retain];

 NSLog(@"check 4");

 [fetchRequest release];

 return returnArray;
}

- (void)addBookmark:(bookmarks_object*)theBookmark
{
 BOOL exists = [self checkIfBookmarkExistsUsingBookmark:theBookmark];

 if(!exists)
 {
  bookmarks *saveBookmark = (bookmarks *)[NSEntityDescription insertNewObjectForEntityForName:@"bookmarks"
                    inManagedObjectContext:self.managedObjectContext];

  [saveBookmark setStation_from:theBookmark.station_from];
  [saveBookmark setStation_to:theBookmark.station_to];
  [saveBookmark setAddDate:[[NSDate alloc] init]];
  [saveBookmark setSort:theBookmark.sort];
  [saveBookmark setPlace:[[NSNumber alloc] initWithInt:([[self getBookmarks] count]+1)]];
  [saveBookmark setName:([theBookmark.type isEqualToString:@"1"] || [theBookmark.type isEqualToString:@"2"] ? theBookmark.station_from : [[NSString alloc] initWithFormat:@"%@ -> %@", theBookmark.station_from, theBookmark.station_to])];
  [saveBookmark setType:theBookmark.type];

  [self saveAction];
  [saveBookmark release];
 }
 else {
  NSLog(@"No need to add, %@ already exists!", theBookmark.station_from);
 }
}

- (BOOL)checkIfBookmarkExistsUsingBookmark:(bookmarks_object*)theBookmark
{
 // Get the categories
 NSArray *historyArray = [self getBookmarks];

 BOOL exists = NO;

 for(bookmarks *dbHistory in historyArray)
 {
  if ([theBookmark.type isEqualToString:@"1"] || [theBookmark.type isEqualToString:@"2"])
  {
   if([[dbHistory station_from] isEqualToString:theBookmark.station_from])
   {
    exists = YES;
    continue;
   }
  }
  else if ([theBookmark.type isEqualToString:@"3"])
  {
   if([[dbHistory station_from] isEqualToString:theBookmark.station_from] && 
      [[dbHistory station_to] isEqualToString:theBookmark.station_to])
   {
    exists = YES;
    continue;
   }
  }
  else {
   NSLog(@"Error! Unknown type!");
   return NO;
  }
 }

 return exists;
}
[...]

Stack trace (Flow: Opening app, load bookmarks view, switch to search view, add bookmark, switch back)

2010-09-19 13:51:54.554 stationen[7256:207] Appear 1
2010-09-19 13:51:54.555 stationen[7256:207] Appear 1 - stage 2
2010-09-19 13:51:54.555 stationen[7256:207] check 1
2010-09-19 13:51:54.560 stationen[7256:207] check 2
2010-09-19 13:51:54.562 stationen[7256:207] check 4
2010-09-19 13:51:54.562 stationen[7256:207] Appear 2
2010-09-19 13:52:26.669 stationen[7256:207] check 1
2010-09-19 13:52:26.670 stationen[7256:207] check 2
2010-09-19 13:52:26.671 stationen[7256:207] check 4
2010-09-19 13:52:26.671 stationen[7256:207] No need to add, 230 already exists!
2010-09-19 13:52:30.509 stationen[7256:207] Release it!
2010-09-19 13:52:30.510 stationen[7256:207] Appear 1
2010-09-19 13:52:30.510 stationen[7256:207] Appear 1 - stage 2
Program received signal:  “EXC_BAD_ACCESS”.
  • 1 1 Answer
  • 1 View
  • 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-17T01:38:10+00:00Added an answer on May 17, 2026 at 1:38 am

    The problem was that the appDelegate somehow was released between the time allocating it and using it.
    I add a retain to it and releasing it just after.

    Found it using NSZombieEnabled as suggested by Mark. Thanks!

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

Sidebar

Related Questions

I have a UITabBarController based application and I want to pass data from one
I have a UITabBarController app where one of the tabs shows the app settings.
I would like for one tab in a UITabBarController to have a fixed position
I have an application that uses a UITabBarController, and inside each tab I have
I have a UITabBarController. One tab is a UINavigationController where it's rootViewController is a
I have a UITabBarController that holds several tabs of which one tab (third Tab,
I have a UINavigationController inside a UITabBarController. When a user presses the first tab,
HEllo, I have a hybrid iPhone application that has a UITabBarController and 5 Tabs.
I have a tabbar application that has one screen that displays statistics based on
I have 5 tab bar items. The first one will be the login page.

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.