In Objective-C I use the following code to
Convert an Int variable into NSData, a packet of bytes.
Int
NSData
int myScore = 0; NS
Depending on the size of Int you are working with, a straight forward approach is to init Data with Sequence of UInt8:
let value: Int = 100 let data = Data([UInt8(value)]) // OR let data = Data([0xFF, 0xFE])