字符串和数组是可以互相转换的,利用一个分隔符来间隔开每个独立元素
用字符将NSArray中的元素拼接起来
<span style="font-size:18px;">- (NSString *)componentsJoinedByString:(NSString *)separator;</span>
将字符串提取元素转换成NSArray
<span style="font-size:18px;">- (NSArray *)componentsSeparatedByString:(NSString *)separator;</span>
<span style="font-size:18px;">//例子:用字符将NSArray中的元素拼接起来 NSArray *array = [NSArray arrayWithObjects:@"hello",@"world",nil]; //如要用,:或其他字符串拼接,只需将下面的@" "空格换成@","或@":"即可 NSString *string = [array componentsJoinedByString:@" "]; NSArray *ary = [string componentsSeparatedByString:@" "];</span>
原文:http://blog.csdn.net/ytuzhangziyao/article/details/43559799