-1

I just opened my project with Xcode 4.1GM (was using 4.0.2 before). When I enter a number in a textfield I get an EXC Bad Access error but the log doesn't provide any info so I can't figure out whats going on. Is there something new in the 4.1 GM that messed this up?

Crash is happening in main.m file at line int retVal = UIApplicationMain(argc, argv, nil, nil);

This is a code that pushes the view and keyboard which is crashing:

- (IBAction)weightButtonPressed
{
    [self.weightView setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:self.weightView];

    BOOL isKgs = [[NSUserDefaults standardUserDefaults] boolForKey:@"isKgs"];
    if (isKgs)
    {
        self.weightLabel.text = @"0 kgs";   
    }
    else
    {
        self.weightLabel.text = @"0 lbs";   
    }
    self.weightTextField.text = nil;

    UIBarButtonItem *acceptButton = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:self action:@selector(dismssPickerSetWeight)];
    self.navigationItem.rightBarButtonItem = acceptButton;
    [acceptButton release];

    [weightTextField addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged];
    self.weightSelectedString = self.weightTextField.text;
    self.weightTextField.hidden = YES;

    [UIView animateWithDuration:.2
                     animations:^
    {[weightTextField becomeFirstResponder]; [self.weightView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];} 
                     completion:^(BOOL finished){}];
}
Jon
  • 4,732
  • 6
  • 44
  • 67

2 Answers2

1

You generally get bad access errors due to over-released objects. I would recommend running your code in instruments with the Zombies profile.

You can do this by holding the run button in Xcode until a list appears, and then selecting 'Profile'.

Katfish
  • 698
  • 7
  • 13
  • For some reason instruments is not working. it is just freezing up on me. – Jon Jul 19 '11 at 00:30
  • You could try setting `NSZombieEnabled` instead. [Instructions here](http://stackoverflow.com/questions/2190227/how-do-i-set-nszombieenabled-in-xcode-4). – Katfish Jul 19 '11 at 00:36
  • I already have NSZombies on, and I restarted my computer and instruments still doesn't work. – Jon Jul 19 '11 at 00:40
  • Ok I got instruments working one time and the app crashed as usual at the number input but there are no leaks recorded. – Jon Jul 19 '11 at 00:42
  • You are not looking for leaks, you are looking for zombies. A zombie is a deallocated object (ref count drops to 0, then you reference the object again), and Instruments should track them for you. [This link](http://www.dimzzy.com/blog/2011/02/hunting-down-zombies-in-ios-apps/) has a brief overview of how to use the Zombies instrument. – Katfish Jul 19 '11 at 15:10
1

Does the stack trace where you crash include [AppleSpell init]?

It's a known bug on Lion with Xcode 4.1 GM seed.

But you installed the final version already, right? Check About Xcode. It should say 4B110. It will probably say 4B95. The Xcode final installer doesn't properly upgrade the seed.

You need to completely uninstall Xcode 4.1 GM seed first for the Xcode installer to do its job. See the About Xcode.pdf in your /Developer folder.

If you're not on the 4.1 branch for whatever reason, you could work around this by turning off autocorrect in your viewDidLoad, but make sure you're using a final build of Xcode for public releases.

Steven Fisher
  • 44,462
  • 20
  • 138
  • 192