将数组拼接成字符串

//字符串转变为数组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:@
","
];

你可能感兴趣的:(将数组拼接成字符串)