Cannot convert value of type 'NSRange' (aka '_NSRange') to expected type 'Range'(aka 'Range')

后端 未结 2 1294
长情又很酷
长情又很酷 2021-02-19 00:15

Getting this error when checking the range for string characters...

@objc func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, re         


        
2条回答
  •  無奈伤痛
    2021-02-19 00:34

    Instead of text! say (text! as NSString).

    var newString = (text! as NSString).stringByReplacingCharactersInRange(range, withString: string) as? NSString
    

提交回复
热议问题