NSString转化为NSData
var string1 = "This is some string"
var nsdata = string1.data(using: String.Encoding.utf8)//NSData 类型
NSData转化为 NSString
let loaclData //这是一段NSdata数据
let str2 = String(data: loaclData, encoding: String.Encoding.utf8)!
print("转化的结果是\(str2)")
网友评论