开发者

Getting EXC_BAD_ACCESS in viewdidunload

开发者 https://www.devze.com 2023-01-04 15:54 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消