是否可以将Data
直接转换为Int64
?
我的解决方案是先转换数据->字符串,然后转换成字符串-> Int64
let data = "123456".data(using: .utf8)! // data from string for example purposes
let idString = String(data: data, encoding: .utf8)! //IUO for example purposes too
let id = Int64(idString)
答案 0 :(得分:0)
您尝试过
let int64Value = data.withUnsafeBytes {
$0.load(as: Int64.self)
}