Reverse a string: Difference between revisions
Content deleted Content added
Line 614: | Line 614: | ||
@implementation NSString (Extended) |
@implementation NSString (Extended) |
||
-(NSString *)reverseString |
-(NSString *) reverseString |
||
{ |
{ |
||
NSUInteger len = [self length]; |
|||
NSInteger l; |
|||
NSMutableString * |
NSMutableString *rtr=[NSMutableString stringWithCapacity:len]; |
||
// unichar buf[1]; |
|||
for(l=[self length]-1; l>=0; l--) |
|||
while (len > (NSUInteger)0) { |
|||
unichar uch = [self characterAtIndex:--len]; |
|||
⚫ | |||
[rtr appendString:[NSString stringWithCharacters:&uch length:1]]; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
@end</lang> |
@end</lang> |