标签:foundation框架 字符串 objective-c string
/*2.将字符串按照单词逆序 输入一段字符串,已知字符串只由字母和空格构成,将字符串按照单词逆序 传入@"welcome to beijing" 返回 @"beijing to welcome" */ + (NSString *)reverseWordsInString:(NSString *)str //{ // NSArray * arr= [str componentsSeparatedByString:@" "]; // NSArray * arr1=[[arr reverseObjectEnumerator]allObjects]; // NSString * str1 = [arr1 componentsJoinedByString:@" "]; // return str1;//[arr copy]; //} //{ // NSArray * array = [str componentsSeparatedByString:@" "]; // NSArray * array1 = [[array reverseObjectEnumerator]allObjects]; // NSString * str1 = [array1 componentsJoinedByString:@" "]; // return str1; //} { NSArray * array = [str componentsSeparatedByString:@" "]; NSArray * array1 = [[array reverseObjectEnumerator]allObjects]; NSString * str1 = [array1 componentsJoinedByString:@" "]; return str1; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:foundation框架 字符串 objective-c string
原文地址:http://blog.csdn.net/u012701023/article/details/47070495