Use UnsafePointer in Swift 3

Swift2

var size = UInt64(dataLength)
let sizeData = NSData(bytes: &size, length: sizeof(UInt64))

Swift3

var size = UInt64(dataLength)
let sizeData = withUnsafePointer(to: &size) {
Data(bytes: $0, count: MemoryLayout.size(ofValue: size))
}

MemoryLayout.size(ofValue:) repalaces sizeof()

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.