Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXC_BAD_ACCESS when calling pushViewController

I have a UITableView inside a UITabBarController.

When I'm calling

[[self navigationController] pushViewController:myViewController animated:YES];

there is no problem.

But, when I'm calling the same line from inside a UIActionSheetDelegate, for example:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

I get EXC_BAD_ACCESS.

It seems that calling this line from a different thread causing this issue.

How can I prevent this EXC_BAD_ACCESS issue?

(notice that myViewController is NOT nil, or something like that)

thanks!

like image 360
taxman Avatar asked Mar 17 '26 14:03

taxman


1 Answers

EXC_BAD_ACCESS is thrown when you try to access a released object, and actionSheet:clickedButtonAtIndex: is called on the main thread, after the action sheet is dismissed, so I'm guessing what's pointed by myViewController is released.

It doesn't have to be nil, in fact, that's the problem. The object pointed is released, but the pointer is not nil.

like image 148
Can Berk Güder Avatar answered Mar 20 '26 06:03

Can Berk Güder