小编m3r*_*3rk的帖子

使用Xcode LLDB控制台调试Swift中的闭包

我坚持使用Xcode LLDB调试控制台的有趣行为.当我使用weak self + guard self语句来防止内存泄漏时,我在尝试打印闭包参数(如示例中的响应)或者闭包中的任何class/struct属性时调试代码时会遇到奇怪的行为.这是一个闭包的例子和print语句的行有一个断点,我试图从Xcode控制台打印响应参数.

Alamofire.request(url).responseJSON { [weak self] response in
    guard let self = self else { return }
    print("This line has a breakpoint and I am trying to print response from debug console")
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用这样的命令:

po response
p response
print response
e response
expression response
Run Code Online (Sandbox Code Playgroud)

总是我得到这样的错误:

    (lldb) po response
error: warning: <EXPR>:12:9: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it
    var $__lldb_error_result = __lldb_tmp_error
    ~~~~^~~~~~~~~~~~~~~~~~~~
    _ …
Run Code Online (Sandbox Code Playgroud)

closures memory-leaks ios lldb swift

14
推荐指数
1
解决办法
1716
查看次数

标签 统计

closures ×1

ios ×1

lldb ×1

memory-leaks ×1

swift ×1