开发者

Getting EXC Bad Access With Xcode 4.1GM

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.weightTextF开发者_开发知识库ield.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){}];
}


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.


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'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜