如何在Swift中将NSRange
转换为Range<String.Index>
?
我想使用以下UITextFieldDelegate
方法:
func textField(textField: UITextField!,
shouldChangeCharactersInRange range: NSRange,
replacementString string: String!) -> Bool {
textField.text.stringByReplacingCharactersInRange(???, withString: string)
发布于 2016-06-25 05:56:57
SWIFT3.0测试版官方文档为这种情况提供了标准解决方案,标题为String.UTF16View ( UTF16View元素匹配NSString字符标题)
https://stackoverflow.com/questions/25138339
复制相似问题