开发者

Getting EXC_BAD_ACCESS on a method call

This is really weird in my perspective. I've never seen anything like it. I put all my releases in a method called releaseMethod. Then in my dealloc and didReceiveMemoryWarning, I have [self releaseMethod]; I do this to be more object orienteted and save code because I have a lot of releases. But, occasionally (2 out of 5 times, give or take), I get EXC_BAD_ACCESS on the releaseMethod call in dealloc. Th开发者_C百科e code is below. I didn't know it was possible to have a method call get bad access. I understand memory management and there is no memory involved in calling a method, right? Thanks in advance.

 - (void)dealloc {
     [super dealloc];
     [self releaseMethod];
 }


Put your [super dealloc] at the end of the dealloc so you can first cleanup things in your class before cleaning up things in the superclass (which you might depend on).


If you send the message release to an object that has already been deallocated, this is the message you will get. Check that you aren't overreleasing something in releaseMethod. Remember, when an object is deallocated, it will release objects that it is retaining.

You should also put [self releaseMethod] before you call [super dealloc].

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜