如何将字符串@“ abc123.xyz789”倒置
//
// main.m
// Text3.2
//
// Created by 123 on 16/1/9.
// Copyright (c) 2016年 com.swl. All rights reserved.
//
#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;
}