Created
February 16, 2014 15:45
-
-
Save yoman07/9036225 to your computer and use it in GitHub Desktop.
Objective-c reversing
the
words
in
a
string
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
- (NSString *) reverseString:(NSString *)str { | |
NSMutableString *reverseString = [[NSMutableString alloc] initWithCapacity:str.length]; | |
for(int i=str.length -1;i>=0;i--) { | |
[reverseString appendString:[NSString stringWithFormat:@"%c", [str characterAtIndex:i]]]; | |
} | |
return reverseString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment