NSString 翻转 字符串

一、

- (id) reverseString
{
    NSUInteger len
= [self length];
   
// self 表示字符串本身
    NSMutableString *retStr = [NSMutableString stringWithCapacity:len];
   
while (len > 0) {
        unichar c
= [self characterAtIndex:--len];
       
// 从后取一个字符 unicode
        NSLog(@" c is %C", c);
        NSString
*s = [NSString stringWithFormat:
                      
@"%C", c];
        [retStr appendString:s];
    }
   
return retStr;
}

二、

get(s);

put(s);

strrev(s)字符串翻转

put(s);

 

你可能感兴趣的:(NSString 翻转 字符串)