开发者

Objective C Make message to nil generate run time error

开发者 https://www.devze.com 2023-01-11 15:54 出处:网络
Is it possible to make messages sent to nil generate some sort of error in run time? I want it for the debugging pur开发者_如何学编程pose.You may want to look into the NSZombieEnabled environment vari

Is it possible to make messages sent to nil generate some sort of error in run time? I want it for the debugging pur开发者_如何学编程pose.


You may want to look into the NSZombieEnabled environment variable.

As @jtbandes said, nil messages are generally a good thing because you can avoid going if (object) [object message] and instead just use [object message]. But a far more important thing to watch out for is sending a message to an object that once existed but has now been freed (without the pointer being nil-ed out). NSZombieEnabled lets you find out when this has happened.

0

精彩评论

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