Ameya
Ameya

Reputation: 1960

Objective-C invalid objects

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

alt text

where as in the log I get Program received signal: “EXC_BAD_ACCESS”.

I require help with the following.

Upvotes: 1

Views: 562

Answers (2)

Conceited Code
Conceited Code

Reputation: 4557

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.

Upvotes: 0

Brock Batsell
Brock Batsell

Reputation: 5803

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.

Upvotes: 2

Related Questions