我试过在类定义中创建一个断点,停止发送给对象实例的消息,希望它跳转到类代码,并允许我逐行浏览并查看本地变量的值。
但是,我要冒险出来说“不,这不应该是可能的” ,因为在内存中可能有多个类的实例。 如果有人能够给出更好的解释,那将是隆重的。
(作为一个方面说明,我的选择是运行时数据过多的NSLogging。)
I've tried creating a breakpoint within a class definition, stopping on the message sent to an object instance, hoping it would then jump to the class code and allow me to walk through line by line and see the values of the local variables.
However, I'm going to venture out and say "no, this should not be possible", as there could be multiple instances of the class in memory. If someone could give a better explanation, that would be grand.
(As a side note, my alternative is excessive NSLogging of the runtime data.)
最满意答案
对的,这是可能的! 您可以将条件添加到断点:
http://d.pr/yZVB+ http://d.pr/pWOB+
条件满足时,程序只会在此断点处暂停。 你可以选择一个条件,比如self == _myGlobalInstanceOfInterest 。
如果不想将实例存储在变量中,例如,可以在没有条件的情况下启动断点 - 然后当程序正在运行时找出想要的实例时,请使用p myObject获取地址,然后设置条件以使用该地址(例如self == 0x8badf00d )。
Yes, it is possible! You can add a condition to a breakpoint:
http://d.pr/yZVB+ http://d.pr/pWOB+
The program will only pause at this breakpoint when the condition is satisfied. You could choose a condition such as self == _myGlobalInstanceOfInterest.
If you don't want to store the instance in a variable, you might, for example, start the breakpoint without a condition — and then when you figure out which instance you want as the program is running, use p myObject to get the address, and then just set the condition to use the that address (such as self == 0x8badf00d).
更多推荐
发布评论