美文网首页
NSString &

NSString &

作者: BlessNeo | 来源:发表于2015-11-30 18:40 被阅读53次

1. 字符串与数组互转

OC

NSMutableString * str=[[NSMutableString alloc]initWithFormat:@"1,1,1,1,1,1"];
//字符串转变为数组
NSMutableArray * array=[NSMutableArray arrayWithArray:[str componentsSeparatedByString:@","]];
//把数组转换成字符串
NSString *ns=[array componentsJoinedByString:@","];

Swift

import UIKit

let str = "1,1,1,1,1"
//字符串转变为数组
let array = str.components(separatedBy: ",")
//把数组转换为字符串
let ns = array.joined(separator: ",")

2.

相关文章

网友评论

      本文标题:NSString &

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