componentsSeparatedByString,componentsJoinedByString,componentsSeparatedByCharactersInSet

将string字符串转换为array数组

 NSArray  *array = [Str componentsSeparatedByString:@","];

 

==反向方法

将array数组转换为string字符串

 

 NSString *tempString = [mutableArray componentsJoinedByString:@","];--分隔符

 

有字符串“A~B^C" ,我拆分为 "A", "B" 和 "C"?

NSString *str = @"A~B^C";

NSArray *arr = [str componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"^~"]];
NSLog(@"%@", arr);

//字符

[NSCharacterSet whitespaceCharacterSet]

 

posted on 2016-12-14 14:41  举个例子yi聪聪  阅读(288)  评论(0编辑  收藏  举报

导航