首页 > 代码库 > 字符串反转,

字符串反转,

-(IBAction)abc:(id)sender

{

    NSString *a = @"abcdef";

    NSMutableString *newA = [[NSMutableString alloc]init];

    int length = a.length;

    for (int i = 0; i<length; i++) {

        char m = [a characterAtIndex:length - i - 1];

        NSString *sM = [NSString stringWithFormat:@"%c",m];

        [newA appendString:sM];

//        [a stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:[NSString stringWithFormat:@"%c",m]];

    }

    TTLog(@"%@",newA);

 

}