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

  • Home
  • SEARCH
  • 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 999055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:17:32+00:00 2026-05-16T07:17:32+00:00

Okay so I am trying to use a simple UINavigationController with iPhone SDK in

  • 0

Okay so I am trying to use a simple UINavigationController with iPhone SDK in Xcode and it works all well when pushing but if go past 2 pushes and try to pop the view controllers I keep getting the error: EXC_BAD_ACCESS

I know what it means but how the heck do I fix it?

Here is my code… (Assume the MainViewController has a button that invokes the function showStartMenu)

FurballAppDelegate.h

//
// FurballAppDelegate.h
// Furball
//
// Created by Morgan Family on 7/28/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>

@class MainViewController, StartViewController, SubjectViewController;

@interface FurballAppDelegate : NSObject <UIApplicationDelegate> {
 UIWindow *window;
 UINavigationController *navController;
 MainViewController *mainController;
 StartViewController *startController;
}

@property (nonatomic, retain) UIWindow    *window;
@property (nonatomic, retain) UINavigationController  *navController;
@property (nonatomic, retain) MainViewController  *mainController;
@property (nonatomic, retain) StartViewController  *startController;

- (void)popBack;
- (void)pushNext:(UIViewController *)next;
- (void)showStartMenu;

@end

FurballAppDelegate.m

//
// FurballAppDelegate.m
// Furball
//
// Created by Morgan Family on 7/28/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "FurballAppDelegate.h"

#import "MainViewController.h"
#import "StartViewController.h"
#import "SubjectViewController.h"


@implementation FurballAppDelegate

@synthesize window;
@synthesize navController;
@synthesize mainController;
@synthesize startController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {

 window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

 mainController = [[MainViewController alloc] init];

 navController = [[UINavigationController alloc] initWithRootViewController:mainController];

 [window addSubview:navController.view];

 [window makeKeyAndVisible];

}


- (void)dealloc {

 [mainController release];
 [startController release];
 [subjectController release];

 [window release];
 [super dealloc];

}


- (void)popBack {
 [navController popViewControllerAnimated:YES];
}


- (void)pushNext:(UIViewController *)next {
 [navController pushViewController:next animated:YES];
}


- (void)showStartMenu {
 startController = [[StartViewController alloc] init];
 [self pushNext:startController];
}


@end

StartViewController.h


//
// StartViewController.h
// Furball
//
// Created by Morgan Family on 8/4/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import 

@interface StartViewController : UIViewController {

}

- (void)showSubjectMenu;

@end

StartViewController.m

//
// StartViewController.m
// Furball
//
// Created by Morgan Family on 8/4/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "FurballAppDelegate.h"
#import "StartViewController.h"
#import "SubjectViewController.h"

@implementation StartViewController


- (void)loadView {

 UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

 UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 [btn setFrame:CGRectMake(50, 50, 100, 30)];
 [btn setTitle:@"DO WORK" forState:UIControlStateNormal];
 [btn addTarget:self action:@selector(chooseSubject) forControlEvents:UIControlEventTouchUpInside];

 [view addSubview:btn];

 FurballAppDelegate *app = [[UIApplication sharedApplication] delegate];

 UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 [btnBack setFrame:CGRectMake(50, 100, 100, 30)];
 [btnBack setTitle:@"DO WORK" forState:UIControlStateNormal];
 [btnBack addTarget:app action:@selector(popBack) forControlEvents:UIControlEventTouchUpInside];

 [view addSubview:btnBack];

 self.view = view;
 [view release];

}


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


- (void)chooseSubject {
 FurballAppDelegate *app = [[UIApplication sharedApplication] delegate];
 SubjectViewController *subjectController = [[SubjectViewController alloc] init];
 [app pushNext:subjectController];
}


- (void)dealloc {
 [super dealloc];
}


@end

All the pushing in all of my files work. Even the “btnBack” when I touch it, pops the navigation controller back to MainViewController… but when I make a back button identical to the one on StartViewController, on the SubjectViewController it gives me that weird error.

I really appreciate any help 🙂

  • 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-16T07:17:33+00:00Added an answer on May 16, 2026 at 7:17 am

    Since you realize it means you’re trying to access an invalid memory address, you need to examine your code for invalid memory accesses.

    Fortunately, for this error, it’s typically right on the line where you receive the EXEC_BAD_ACCESS. Look at the objects and pointers on that line. Do they all make sense? If not, back up a line. Wash, rinse and repeat. Somewhere you’re not allocating an object properly, are releasing it too early, have stack corruption, or some variable pointing to random garbage.

    Posting some of the code around where you receive the error might allow us to spot the error. However, it’s also possible that it’s impossible to see without being able to single-step through in the debugger.

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

Sidebar

Related Questions

Okay, here's what I'm trying to do: I'm trying to use PHP to develop
OKay I don't use actionscript and trying to help my friend edit a flash
Okay so what i am trying to achieve is use the youtube api to
Okay I been trying to work this out but unable too. I have a
trying to use the preferred on method call but the code is not working
I'm trying to use the min_element for array of structures, but I simply can't
Okay, so i've got paperclip working, and I'm trying to use the built in
Okay, I'm trying to create a simple app that will draw a shape (I'm
I'm trying to use simple_html_dom to remove all the spans from a snippet of
Okay, I'm a newbie in C# but I need to create a simple GUI,

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.