I follow this answer to trace my app for EXC_BAD_ACCESS. Yes, I got a zombie object. When I'm trying to figure out which line of my code is wrong, I found that all of the Responsible Libraries are Foundation.
When I'm trying to do this:
When you double click on any retain/release, instruments will show you line of code where this was performed.
It always takes me to some code with assembly language.
[
I don't know how to trace my bug like this...
Update according to the answer of Elike.
The bug did happened when I update the title of a button. I use a timer to update a button title per second. You can tap the button to start/stop it. And I use dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_auto_duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{});
to auto run the method for 300 times (the bug happens randomly during 300 times).
I call the Timer like this
_startcounttimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(StartCountTimerMethod) userInfo:nil repeats:YES];
- (void)StartCountTimerMethod
{
_startcountbtnsec++;
NSString *secstring = [NSString stringWithFormat:@"%d", _startcountbtnsec];
[_startbtn setTitle:secstring forState:UIControlStateNormal];
}
And tap on the button will call this method:
- (void)StartBtnClick:(UIButton *)btn
{
switch (btn.tag) {
case 0:
btn.tag = 1;
[_startbtn setTitle:@"0" forState:UIControlStateNormal];
_startcountbtnsec = 0;
[self StartCountTimerStart];
NSLog(@"Start!");
break;
case 1:
btn.tag = 0;
[_startbtn setTitle:@"Start" forState:UIControlStateNormal];
[self StartCountTimerStop];
NSLog(@"Stop!");
break;
default:
break;
}
}
I can't see any problem with updating button text... And the zombie object is "NSThread".Is there any chance that the bug is about button and thread?