在 Xcode 中,LLDB 可以在调试时通过 expr 命令更改变量值(参见 How to change variables value while debugging with LLVM in XCode? )。我用这个方法成功地改变了一个字符串值,但是当我改变一个NSURL变量到一个新的实例时,我得到了一个错误:
(lldb) expr url = [NSURL URLWithString:@"www.example.com"];
error: no known method '+URLWithString:'; cast the message send to the method's return type
error: 1 errors parsing expression
如何将 url 更改为新值?谢谢。
最佳答案
您可以尝试显式转换,即
expr url = (NSURL *)[NSURL URLWithString:@"www.example.com"];
因为LLDB有时获取不到返回类型。例如,
// You should specify the return type here:
expr (int)[UIApplication version]
// instead of
expr [UIApplication version]
关于ios - 使用 expr 命令在 XCode 中使用 LLVM 进行调试时如何更改 NSURL 变量值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17984729/