美文网首页
swift Data转string 以及 [bytes]转

swift Data转string 以及 [bytes]转

作者: 誓言_acaa | 来源:发表于2018-10-16 17:09 被阅读0次

data 转string

func string(from data: Data) -> String {
        return String(format: "%@", data as CVarArg)
    }

[bytes]转NSData

let bytes:[UInt8] = [0x07,0x4d,0x45,0x53,0x48,0x31,0x32,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
let data = NSData(bytes: bytes, length: bytes.count)
print(data)

相关文章

网友评论

      本文标题:swift Data转string 以及 [bytes]转

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