#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {

@autoreleasepool {

//如何将字符串@“ abc123.xyz789”倒置

NSMutableString *str=@" abc123.xyz789";

NSLog(@"原字符串为:%@",str);

NSMutableArray *arr=[[NSMutableArray alloc]init];

NSRange rang;

for (int j=str.length-1; j+1 != nil; j--) {

rang.location=j;

rang.length=1;

NSString *newStr3=[str substringWithRange:rang];

//NSLog(@"%@",newStr3);

[arr addObject:newStr3];

}

NSString *join=[arr componentsJoinedByString:@""];

NSLog(@"倒置已后为:%@",join);

}

return 0;

}

05-22 07:18