how to reverse a nsstring
原文:http://lovebirdegg.co.tv/2010/04/how-to-reverse-a-nsstring/ 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);