简体   繁体   English

如何在Xcode Debugger中调用嵌套的Swift函数?

[英]How to call nested Swift function in Xcode Debugger?

In Xcode Debugger, how can I call a function inside of a function? 在Xcode Debugger中,如何调用函数内部的函数?

Code ( errorMessage is an instance method, and firstName & lastName are properties of self .) 代码( errorMessage是一个实例方法, firstNamelastNameself属性。)

func errorMessage() -> String? {
    func isValidName(name: String) -> Bool {
        return 1...50 ~= name.characters.count
    }

    var nameType: String?
    if !isValidName(firstName) {
        nameType = "First"
    } else if !isValidName(lastName) {
        nameType = "Last"
    }

    if let messagePrefix = nameType {
        return "\(messagePrefix) name must be between 1 & 50 characters."
    } else {
        return nil
    }
}

Debugger (while stopped at the first if statement above) 调试器(在上面的第一个if语句处停止)

(lldb) p isValidName("Matt")
error: <EXPR>:1:1: error: use of unresolved identifier 'isValidName'
isValidName("Matt")
^~~~~~~~~~~

This is a bug. 这是一个错误。 There's already a report of it, but if you want to file another at http://bugreporter.apple.com we'll dup it to the original and you'll get notified when the original is resolved. 已经有了它的报告,但如果您想在http://bugreporter.apple.com上提交另一份报告,我们会将其复制到原始版本,并在原件解决后收到通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM