ios 字符串逆转

- (NSString *)stringByReversed:(NSString *)str
{
    NSMutableString *mutableSgtr = [[NSMutableString alloc]init];
    for (NSInteger i = str.length; i>0; i--) {
        [mutableSgtr appendString:[str substringWithRange:NSMakeRange(i-1, 1)]];
    }
    return mutableSgtr;
}

你可能感兴趣的:(ios 字符串逆转)