开发者

Objective-C invalid objects

开发者 https://www.devze.com 2023-01-06 14:43 出处:网络
Can any one guide me with invalid objects created in Objective-C. I am working on iPhone SDK. I see invalid objects created in the application which crashes the application.

Can any one guide me with invalid objects created in Objective-C. I am working on iPhone SDK. I see invalid objects created in the application which crashes the application.

Here is a screen shot of how it looks

Objective-C invalid objects

where as in the log I get Progra开发者_运维知识库m received signal: “EXC_BAD_ACCESS”.

I require help with the following.

  • How are they created.
  • How to prevent them.
  • How to detect them.


That error means you sent a message to an object that had already been released (in other words, the retain count of some object reached zero, so you're over-releasing that object somewhere). In Xcode, you can set NSZombieEnabled to YES in your Debug environment; that will make objects that should be released stick around, and then when a zero-count object is messaged, the debugger should break, you'll get a log entry showing what object was over-released as well as your usual call stack and such.

Make sure to only use NSZombie when you're trying to find an over-released object.


I can't see your screen shot, but EXC_BAD_ACCESS is given to you when you are access an object that is usually released before you use it. You can't really prevent coding that, it happens to all of us at some point or another. You're just gonna have to learn how to find your code that is access the object and learn to fix it.

Turn on NSZombies your gonna have to debug your application. Google how to use NSZombies and that should help you find your problem.

0

精彩评论

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