NSString *str1=@"I am Lv Chen Hao";
NSArray *arr1=[str1 componentsSeparatedByString:@" "];
NSMutableArray *arr2=[NSMutableArray arrayWithCapacity:0];
NSEnumerator *enumer=[arr1 reverseObjectEnumerator];//逆序遍历数组
NSString *str;
while (str=[enumer nextObject])
{
[arr2 addObject:str];
}
NSString *newStr=[arr2 componentsJoinedByString:@" "];
NSLog(@"newStr=%@",newStr);
时间: 2024-11-15 21:28:08