I have an UI button and it works correctly when I pressed.
But if I press the button three times, I get an EXc_BAD_ACCESS error.
I thought I release something in somewhere but I couldn’t find the solution.
Could you please help me?
Kind regards.
This is the function when I pressed the button. And in dealloc I release them. When I am tracking, it doesn’t give the error in function. I got it after function, but I dont know where the code goes after this function.
- (IBAction) doSomething: (id)sender
{
[self.answerDict replaceObjectAtIndex:currentPageNumber withObject:@"1"];
[self.b setImage:nil forState:UIControlStateNormal];
[self.c setImage:nil forState:UIControlStateNormal];
[self.d setImage:nil forState:UIControlStateNormal];
[self.e setImage:nil forState:UIControlStateNormal];
UIImage *img = [UIImage imageNamed:@"a.jpg"];
[self.a setImage:img forState:UIControlStateNormal];
[img release];
}
[img release];is the problem. You are releasing an object which you dont own.imgin this case is auto-released.Remove
[img release];and see if the crash occurs