We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f934f7a commit 33a8469Copy full SHA for 33a8469
VSTwitterTextCounter/Classes/VSTwitterTextCounter.swift
@@ -361,7 +361,7 @@ public class VSTwitterTextCounter: UIControl
361
let objcString = NSString(string: textView.text)
362
363
// Find if last allowed index falls between a unicode character
364
- var lastAllowedCharacterIndex = maxCount // Last allowed character index
+ var lastAllowedCharacterIndex = objcString.length > maxCount ? maxCount : objcString.length - 1 // Last allowed character index
365
let rangeOfComposedCharacter = objcString.rangeOfComposedCharacterSequence(at: lastAllowedCharacterIndex)
366
if rangeOfComposedCharacter.contains(lastAllowedCharacterIndex)
367
{
0 commit comments