NSArray *arr3=@[@"one",@"two",@"three"]; NSString *str=[arr3 componentsJoinedByString:@"-"];//把数组用--链接成字符串 NSLog(@"%@",str);//结果为:one-two-three NSString *str2=@"abc-dfgg-sda"; NSArray *arr4=[str2 componentsSeparatedByString:@"-"];//把字符串分成字符数组 NSLog(@"%@",arr4); //结果为{abc, dfgg, three }
|