Exc_bad_access (code=1, address=0x789870) Wild pointer error

Source: Internet
Author: User

iOS Development Note----exc_bad_access (code=1, address=0x789870) Wild pointer error, suspended animation debug State
2014-04-30 I say two words Source: iOS Development Note----exc_bad_access (code=1, address=0x789870) Wild pointer error, suspended animation debug State
Collection I want to contribute

Cause of Error:

Exc_bad_access (code=1, address=0x789870) Wild pointer error, the main reason is that when an object is completely released, that is, Retaincount, the reference count is 0. A wild pointer error occurs when another method is called by the object.

For example:

Person *jerry = [[Person alloc]init]; Retaincount reference count is 1

[Jerry Eat]; Call the Eating method

[Jerry Release]; Release Jerry This object to the Retaincount reference count of 0

At this point, if you continue to reference Jerry This object will have a wild pointer error, exc_bad_access

[Jerry Sleep];

Workaround:

First of all to locate where the presence of such a wild pointer reference error, if it is a large project code size, it is very painful to find.

iOS provides an environment variable setting to help locate the information description for the wrong location: nszombieenabled , that is, when the nszombieenabled environment variable is set, an object is converted to _nszombie when it is destroyed. When you set nszombieenabled, when you send a message to an object that has already been disposed of, the object does not crash or create an incomprehensible behavior, but instead emits an error message and disappears in a predictable way that produces a debug breakpoint. So we can find specific or presumably which object has been wrongly released.

For example, a hint like this would appear:

[Jerry Sleep]:message sent to deallocated instance 0x78d7ed0

Set the nszombieenabled environment variable, in XCODE4:

You can click the Xcode4 menu Product, Edit scheme-> Arguments, and then click "Plus" to add the nszombieenabled parameter to the Environment Variables window, followed by the number Write "YES" on the value.

Or, in the Xcode4 menu Product, Editscheme, Diagnostics Settings window, simply tick enable zombieobjects, Xcode can be cmd+shift+< into this window.

Exc_bad_access (code=1, address=0x789870) Wild pointer error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.