Last active
August 29, 2015 14:07
-
-
Save austinzheng/d694393296a5c932f994 to your computer and use it in GitHub Desktop.
Hakawai transformer example
This file contains hidden or 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
// Text transformer (palindrome) | |
[self.textView transformSelectedTextWithTransformer:^NSAttributedString *(NSAttributedString *input) { | |
NSString *rawInput = [input string]; | |
NSMutableString *buffer = [NSMutableString string]; | |
unichar stackC; | |
for (NSInteger i=[rawInput length] - 1; i>=0; i--) { | |
stackC = [rawInput characterAtIndex:i]; | |
[buffer appendString:[NSString stringWithCharacters:&stackC length:1]]; | |
} | |
NSDictionary *attrs = [input attributesAtIndex:0 effectiveRange:NULL]; | |
return [[NSAttributedString alloc] initWithString:buffer attributes:attrs]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment