日期:2014-05-16  浏览次数:20999 次

查看EXC_BAD_ACCESS或SIGABRT的方法

本文出自:http://blog.csdn.net/linhanmin/article/details/8117808


1.打开XCode -> Product -> Edit Scheme 

2.选择Arguements的Environment Varibles中添加NSZombieEnabled YES


测试代码

UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(0,0,102,102)];

[label release];

[self.view addSubview:label];


使用前结果:

-[NSPathStore2 frame]: unrecognized selector sent to instance 0x1f55eff0

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPathStore2 frame]: unrecognized selector sent to instance 0x1f55eff0'

代码跳回main函数


使用后:

 -[UILabel superview]: message sent to deallocated instance 0x1fd30540