字符串反转

字符串倒叙
NSString *abcd = @”abcd”;
NSMutableString *dcba = [[NSMutableString alloc]initWithCapacity:abcd.length];

for (int i = abcd.length-1 ; i >= 0 ; i–) {
[dcba appendFormat:@”%c”, [abcd characterAtIndex:i]];//注意这里返回的是char
}
NSLog(@”dcba is %@”, dcba);

    原文作者:Eidesen
    原文地址: https://segmentfault.com/a/1190000004608555
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞