Search code examples
iphoneobjective-cxcodenszombie

Can't get Zombies to work in XCode


I'm trying to solve my first really hard EXC_BAD_ACCESS problem. I see from a lot of tutorials and blogs that I can use Zombies to help me figure out where I'm going wrong. But I don't think my zombies are working, and I'm DEFINATELY not getting anything useful out of the console.

When I start the program I see this: This GDB was configured as "x86_64-apple-darwin".Setting environment variable "NSZombieEnabled" to null value.

Eventually, I see a couple of NSLog traces I used and then:

Program received signal:  “EXC_BAD_ACCESS”.

No help at all. Any ideas? I have a sneaking suspicion that even with the zombies working it won't be able to tell me where the bad access happened. Objective C makes me sad--This would have taken 3 seconds in ActionScript :(


You say the crash is here (edit the question next time):

- (IBAction) toggleView{
if(switchableView.subviews.count != 0)
    [[switchableView.subviews objectAtIndex:0] removeFromSuperview];
UIViewController* newView = (viewSelector.selectedSegmentIndex == 0) ? [Login new] : [UserRegistration new];
[switchableView addSubview:newView.view];
//[newView release];
}

Solution

  • Actually you are getting something useful from the console. It's telling you that you haven't enabled NSZombie - "Setting environment variable "NSZombieEnabled" to null value."

    The value needs to be YES not null.

    Executables -> Your Target Name -> Arguments -> Variables to be set in the environment

    Even without NSZombies enabled it should be very straightforward to see where your bad access is from your call stack. Action script is a scripting language.