字符串反转,

-(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);

 

}

posted @ 2014-07-03 15:47  路在脚下,  阅读(149)  评论(0编辑  收藏  举报