3

In Xcode Debugger, how can I call a function inside of a function?

Code (errorMessage is an instance method, and firstName & lastName are properties of self.)

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)

(lldb) p isValidName("Matt")
error: <EXPR>:1:1: error: use of unresolved identifier 'isValidName'
isValidName("Matt")
^~~~~~~~~~~
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • 1
    the problem looks very much fixed in this discussion here http://stackoverflow.com/questions/28497533/po-gives-error-expr11-error-use-of-unresolved-identifier – Raica Dumitru Cristian Nov 04 '15 at 15:03

1 Answers1

1

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.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63