Skip to content

Instantly share code, notes, and snippets.

@yoman07
Created February 16, 2014 15:45
Show Gist options
  • Save yoman07/9036225 to your computer and use it in GitHub Desktop.
Save yoman07/9036225 to your computer and use it in GitHub Desktop.
Objective-c reversing 
the 
words 
in 
a 
string
- (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