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

时间:2015-11-04 13:39:32

标签: xcode swift debugging nested-function

在Xcode Debugger中,如何调用函数内的函数?

代码(errorMessage是一种实例方法,而firstName& lastNameself的属性。)

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
    }
}

调试器(在上面的第一个if语句处停止)

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

1 个答案:

答案 0 :(得分:1)

这是一个错误。已有关于它的报告,但如果您想在http://bugreporter.apple.com处提交另一份报告,我们会将其复制到原始报道,并在原件解决后收到通知。

相关问题