EXC_BAD_ACCESS (code=1 address=0x0) at runtime

EXC_BAD_ACCESS (code=1 address=0x0) at runtime

Ok, you might be laughing at the end of this post, but I thought it is better if I put this into a searchable form, and you might in the same situation as me.

In a nutshell: I modified the signature one of my class’s initializer, this class was actually a subclass of the UIView, and after the modification every time I tried to access those class Xcode stopped with the error: EXC_BAD_ACCESS (code=1 address=0x0). It was so frustrating, that Xcode dropped me neither a build-time error nor any particular error in the error log. I spent almost a day digging into topics in StackOverflow without any solution. I have also checked the debugger, actually the view wasn’t null.

I don’t want to tease you more, so [drum rolling…]:

Actually, and accidentally I deleted the reference message call from the initializer to the superview, so this line was missing from my UIView implementation’s initWithFrame: initializer:
self = [super initWithFrame:frame];.

My bad. Hopefully next time I (and hopefully you as well;)) will find this post quicker than the other posts in the StackOverflow;).


Leave a Reply