How to generate UUID in ios

后端 未结 7 823
北海茫月
北海茫月 2020-11-30 20:59

How to get a UUID in objective c, like in Java UUID is used to generate unique random numbers which represents 128 bit value.

7条回答
  •  半阙折子戏
    2020-11-30 21:35

    For Swift 5.0, Use this,

        let uuidRef = CFUUIDCreate(nil)
        let uuidStringRef = CFUUIDCreateString(nil, uuidRef)
        let uuid = uuidStringRef as String? ?? ""
    

提交回复
热议问题