使用componentsSeparatedByString将字符串分隔成NSArray 数组

代码如下:

NSString *st = @"wta,wtb,wtc,wtd,wte,wtf,wtg,wth,wti,wtj";

NSArray *sarray = [st componentsSeparatedByString:@","];

for (int i=0; i<[sarray count]; i++) {

NSLog(@"value:%@",[sarray objectAtIndex:i]);

 

使用componentsJoinedByString 将字符串连接成字符串。

代码如下:

NSString *join=[sarray componentsJoinedByString:@"---"]; 

 

相关文章:

  • 2021-08-20
  • 2022-12-23
  • 2021-09-01
  • 2021-05-22
  • 2022-12-23
  • 2021-07-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案