How to convert an Int into NSData in Swift?

前端 未结 7 1906
陌清茗
陌清茗 2021-02-03 22:37

In Objective-C I use the following code to

  1. Convert an Int variable into NSData, a packet of bytes.

    int myScore = 0;
    NS         
    
    
            
相关标签:
7条回答
  • 2021-02-03 23:05

    Use this initializer to convert every Array to Data

    Data(element: Sequence)
    

    example:

    let myArr     = [12,45,67,898, 100]
    let myArrData = Data(myArr)
    
    0 讨论(0)
提交回复
热议问题