Created
October 15, 2012 21:47
-
-
Save mlaster/3895770 to your computer and use it in GitHub Desktop.
NSString and character composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)textView:(UITextView *)inTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
BOOL retValue = NO; | |
NSUInteger newCharCount = [[inTextView text] length] - range.length + [text length]; | |
NSMutableString *newString = [[inTextView text] mutableCopy]; | |
[newString appendString:text]; | |
NSLog(@"newString: [%@]", newString); | |
NSLog(@"original newCharCount: %ld", (long)newCharCount); | |
newCharCount = [newString length]; | |
NSLog(@"new newCharCount: %ld", (long)newCharCount); | |
if (newCharCount <= self.characterLimit) { | |
retValue = YES; | |
} | |
return retValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment