Charly Pico Charly Pico - 6 months ago 111
iOS Question

Ambiguous Reference: UITextField.text error Swift 3

So I've just updated to Xcode 8 and converted my Swift 2.3 code to Swift 3, and I have an error in this line of code that wasn't in Swift 2.3:

let holder:NSString! = NSString.init(string: moneyBar.text!).substring(with: NSRange.init(location: y, length: 1))

Now in Swift 2.3 the line has no error, but in Swift 3 it looks like the
is marked with the error
Ambiguous reference to member 'text'.

Is this a Swift 3 bug? Or I'm missing something?


I think the syntax you want is:

let holder = NSString(string: moneyBar.text!).substring(with: NSRange(location: y, length: 1))