ios - 使用 expr 命令在 XCode 中使用 LLVM 进行调试时如何更改 NSURL 变量值?

标签 ios lldb

在 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/

相关文章:

ios - 从单应性或使用 solvePnP() 函数估计相机姿态

ios - 在 iOS 6 的 UITableView 中保留此 JSON 数据以使用的最佳方式

iphone - 检查电子邮件是否有效

html - 从 iOS 应用程序中的远程 HTML/json 项目读取 json

ios - 带有静态单元格的 UITableView 中的自定义单元格类

c++ - 在 gdb 中,在我按下 tab 后,它可以完成我的命令以及局部变量,但是为什么 lldb 不能

iphone - 我无法使用这个简单的 LLDB 别名

c - 整数指针缓冲区跳过索引

ios - 无法在控制台(调试区)使用 po 命令

Xcode:如何退出lldb swift repl