本人亲测有效!更多交流可以家魏鑫:lixiaowu1129,公重好:iOS过审汇总,一起探讨iOS技术!
字符串与Data的转换
var send: String = "hello"
let data: Data = send.data(using: .utf8)!
let receive: String = String(data: data, encoding: .utf8)!
print(receive)
Int与Data的转换
var send1: Int = 199
var data1: Data = Data(bytes: &send1, count: 8)
var receive1: Int = 0
(data1 as NSData).getBytes(&receive1, length: 8)
print(receive1)
本文由mdnice多平台发布
网友评论