原文:[url]http://lovebirdegg.co.tv/2010/04/how-to-reverse-a-nsstring/[/url]
some time you want to recerse a nsstring
for example:
"你好"to"好你"
i Searched the api but have no result,the method above can solute it
some time you want to recerse a nsstring
for example:
"你好"to"好你"
i Searched the api but have no result,the method above can solute it
NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
int len = [content length];
// Auto released string
NSString * reversedStr = [[NSMutableString alloc] init];
// Probably woefully inefficient...
while (len > 0)
[reversedStr appendString:
[NSString stringWithFormat:@"%C", [content characterAtIndex:--len]]];
NSLog(reversedStr);