Generate a UUID on iOS from Swift

前端 未结 6 1743
一向
一向 2020-12-12 09:20

In my iOS Swift app I want to generate random UUID (GUID) strings for use as a table key, and this snippet appears to work:

let uuid = CFUU         


        
6条回答
  •  离开以前
    2020-12-12 10:05

    Try this one:

    let uuid = NSUUID().uuidString
    print(uuid)
    

    Swift 3/4/5

    let uuid = UUID().uuidString
    print(uuid)
    

提交回复
热议问题