Created
June 22, 2013 12:23
-
-
Save TomLiu/5840696 to your computer and use it in GitHub Desktop.
NSString+reverse
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
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