美文网首页
将数组拼接成字符串

将数组拼接成字符串

作者: PlatonsDream | 来源:发表于2016-06-26 01:24 被阅读80次

    //字符串转变为数组1

    NSMutableString

    • str=[[
      NSMutableString
      alloc]initWithFormat:@
      "1,1,1,1,1,1"
      ];

    //字符串转变为数组2

    NSMutableArray

    • array=[
      NSMutableArray
      arrayWithArray:[str componentsSeparatedByString:@
      ","
      ]];

    //替换数组中的某个值

    [array replaceObjectAtIndex:4 withObject:@
    "2"
    ];

    //把数组转换成字符串

    NSString
    *ns=[array componentsJoinedByString:@
    ","
    ];

    相关文章

      网友评论

          本文标题:将数组拼接成字符串

          本文链接:https://www.haomeiwen.com/subject/zcbadttx.html