Exc_bad_access


#1

Using Xcode 4.1 on Lion.

When running HypnoTime, I get an abend/error of ‘Thread 1: Program received signal: “EXC_BAD_ACCESS”.’ It occurs on the 3rd time that I select between the tabs ‘Hypnosis’ and ‘Time’. Both views show up correctly, its just after I attempt to switch the 3rd time that the program abends (it shuts down the app and goes to the main screen). I’ve double checked my code against the solution and don’t see any differences.

I’ve also done a search for the condition code and ran the Zombie profiler in order to track down the issue (per this post). The profile runs, but never locates anything - even though the application does abend. In fact the instruments screen doesn’t respond to anything I do (even telling it to quit). Shutting down now to see if that forces Instruments down.

I’m still researching the issue, but thought I’d post here in case someone already knew of the solution.

Thank you,
Brian.


#2

One of the comments at the link you provided says:

Perhaps the same applies here. It’s hard to say without seeing code.


#3

I had the same problem/error as described above…

So I decided to start all over again with this assignment and tried to debug from the beginning…

And already after the first simple things, setting up the tabbar and adding the (empty) viewcontrollers to the tabbar, I got an error when I try to select the second tab:

[quote]2012-01-20 12:03:38.389 HypnoTime[1626:f803] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “CurrentTimeViewController” nib but the view outlet was not set.’
*** First throw call stack:[/quote]

Apart from creating the empty viewcontrollers, this is all I did:

[code]- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// create tabcontroller
UITabBarController *tabBarController = [[UITabBarController alloc] init];

// create two view controllers
UIViewController *vc1 = [[HypnosisViewController alloc] init];
UIViewController *vc2 = [[CurrentTimeViewController alloc] init];

// make an array
NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, nil];

// array retains, so release responsibility
[vc1 release];
[vc2 release];

// attach vc's to tabbar
[tabBarController setViewControllers:viewControllers];

// set tabbar as root viewcontroller
[[self window] setRootViewController:tabBarController];

// window retains, so we can release it
[tabBarController release];

[[self window] makeKeyAndVisible];
return YES;

}
[/code]

Anyone any idea what this could be?


#4

It complains about the following lines in Main.m

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

and at the return line it says: Thread1: Program received signal: “SIGABRT”

It is really weird… in the previous attempt this worked fine… It’s alomst as if it has the previous project in cache or something…

The only thing I did different is that I made a few groups where I put my classes in. , , , … but that shouldn’t be the problem right? :-S


#5

The error message you posted does a good job explaining what is wrong.

[quote]2012-01-20 12:03:38.389 HypnoTime[1626:f803] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “CurrentTimeViewController” nib but the view outlet was not set.’
*** First throw call stack:[/quote]

This is saying “Hey, I tried to load CurrentTimeViewController.xib, but the view was not hooked up, so I’m going to crash”. Open CurrentTimeViewController.xib. Open the Utilities area (command-option-0 <-that’s a zero). Open the Identity inspector tab (3rd tab). Make sure the class at the top is CurrentTimeViewController. Next, right click on File’s Owner. You should see a view outlet that you can connect. Connect this to the root/main view in the xib file.

Run the program, and you should hopefully not see that error anymore. :slight_smile:

Anytime you see “loaded the ___ nib but the ___ outlet was not set”, check the xib file (recall, xib files get compiled into nib files, so although it is complaining about the nib, we need to open the pre-compiled file, the xib file) to make sure that the outlet it mentions in the error message is hooked up properly.

Hope that helps, let me know if you have questions.


#6

Also, regarding it crashing on main.m, this is a bug with Xcode 4.2. The issue will never be in main.m (assuming you haven’t changed the code there, which there is no reason to), so try using the error message (if one was provided), or try to step through your code line by line to see where the problem occurs.