Getting EXC_BAD_ACCESS in viewdidunload
I am getting exception on few of my ViewControllers when I go through browsing the application.
The exception is occurring in viewdidunload, I think this is due to memory warning. The following line gets an exception which are the IBOulet objects.
self.LabelDistance = nil;
self.distanceSlider = nil;
Pleas开发者_开发知识库e help. Thanks
Why would you want to set this to nil?
If it's a @property (retain) UILabel * labelDistance;
(and synthesized), then just release
it in dealloc
. Or do you fiddle with that ivar around?
One note: your variable and property should begin with a lower letter "l".
Try:
[self.labelDistance release];
[self.distanceSlider release];
instead. Also, you shouldn't be releasing ivars in viewDidUnload
, release them in dealloc
. If the problem persists, run the static analyzer (Build menu >> Build and Analyze), it is generally good at finding memory related issues.
精彩评论