Skip to content

Instantly share code, notes, and snippets.

@TomLiu
Created June 22, 2013 12:23
Show Gist options
  • Save TomLiu/5840696 to your computer and use it in GitHub Desktop.
Save TomLiu/5840696 to your computer and use it in GitHub Desktop.
NSString+reverse
NSMutableString *reversedString = [NSMutableString string];
NSInteger charIndex = [myString length];
while (charIndex > 0) {
charIndex--;
NSRange subStrRange = NSMakeRange(charIndex, 1);
[reversedString appendString:[myString substringWithRange:subStrRange]];
}
NSLog(@"%@", reversedString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment