开发者

How can I make a break point at the specific [nsstring release] without subclassing NSString?

开发者 https://www.devze.com 2023-02-15 16:40 出处:网络
Can I make a break point at the specific NSString object\'s release message? for example: if (phoneNumber) [phoneNumber release];

Can I make a break point at the specific NSString object's release message?

for example:

if (phoneNumber) [phoneNumber release];
phoneNumber = [newPhone retain];

then, I want to set a break point at the phoneNumber's release method, and I don't want to subclass NSString to set a break point at the release method.

is it possible? I think it i开发者_如何学运维s possible, and I'm still googling.


To answer the specific question, you would use a conditional breakpoint. Create a global variable, assign the string you want to break on into that global variable, set a breakpoint on -release, then use the conditional breakpoint to break when needed.

But that is all [most likely] a complete waste of time. As a guess, I'm betting you are trying to track down a retain/release problem? ... an over-release, perchance?

In any case, Instruments will quite conveniently track all retain/releases of all objects. It will also detect over-releases. Other tools can easily be used to track over-retains.

Having to track the release of a particular string object is generally only something you do out of desperation, having exhausted the vast variety of other tools.

0

精彩评论

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