Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func changeText(_ range: NSRange, replacementText text: NSString) {
- if validInputStarted {
- if stringRange.location >= range.location && stringRange.location < range.location + range.length {
- validInputStarted = false
- } else if range.location < stringRange.location {
- stringRange.location -= range.length - text.length
- } else if range.location > stringRange.location && range.location <= stringRange.location + stringRange.length {
- stringRange.length -= stringRange.length - (range.location - stringRange.location) - text.length
- }
- var str = "";
- if stringRange.location + 1 < (textView.text as NSString).length {
- str = (textView.text! as NSString).substring(with: NSRange(location: stringRange.location + 1, length: stringRange.length - 1))
- }
- }
- if text.length > 0 && (text as NSString).substring(to: 1) == "@" {
- validInputStarted = true
- stringRange.location = range.location
- stringRange.length = text.length
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement