在XCode中调试时如何更改NSString值? [英] how to change NSString value while debugging in XCode?

查看:346
本文介绍了在XCode中调试时如何更改NSString值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在XCode的断点停止时,我可以看到NSString变量的值。我该怎么改?我可以改变int或double变量,而不是NSString。

When I'm stopped at a break point in XCode, I can see the value of NSString variables. How can I change them? I can change int or double variables, but not NSString.

推荐答案

你可以在调试控制台中执行此操作。假设你有 NSString * myVar 。在控制台中,在(gdb)之后,键入设置myVar = @我的新字符串。如果您使用(lldb),则使用等价的表达式 expr myVar = @我的新字符串

You can do this in the debug console. Say you have NSString* myVar. In the console, after (gdb), type set myVar = @"My new string". If you are using (lldb), then use the equivalent expression expr myVar = @"My new string" instead.

变量面板中可能无法正确显示,但您可以通过输入 po myVar 来验证该值控制台。您的代码应该接收新的值。

This may not show up correctly in the variables panel, but you can verify the value by entering po myVar into the console. Your code should pick up the new value.

有关使用 expr 的一些很好的信息,请查看这个StackOverflow文章

For some great info about using expr, check out this StackOverflow post.

这篇关于在XCode中调试时如何更改NSString值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆