gpt4 book ai didi

swift - 将 NSTimeInterval 转换为 NSData 并返回 NSTimeInterval

转载 作者:行者123 更新时间:2023-11-28 09:32:42 26 4
gpt4 key购买 nike

如何将 NSTimeInterval 值转换为 NSData

最佳答案

Xcode 8.3.1 • Swift 3.1

var nowInterval = Date().timeIntervalSince1970                                  // 1491800604.362141
let data = Data(bytes: &nowInterval, count: MemoryLayout<TimeInterval>.size) // 8 bytes
let timeInterval: Double = data.withUnsafeBytes{ $0.pointee }

let date = Date(timeIntervalSince1970: timeInterval) // Apr 10, 2017, 2:03 AM"

关于swift - 将 NSTimeInterval 转换为 NSData 并返回 NSTimeInterval,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33653208/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com