18
Ottenere questo errore quando si controlla l'intervallo per caratteri stringa ...Impossibile convertire il valore di tipo "NSRange" (aka "_NSRange") nel tipo previsto "Intervallo <Index>" (noto anche come "Intervallo <String.CharacterView.Index>")
@objc func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
let shouldChange = false
let text = textField.text
var newString = text!.stringByReplacingCharactersInRange(range, withString: string) as? NSString
if newString.length > 14{
newString = newString.substringToIndex(14)
}
textField.text = newString.uppercaseString
return shouldChange
}
Compare [NSRange alla gamma] (http://stackoverflow.com/questions/25138339/nsrange-to-rangestring-index). –