NSFileManager unique file names

前端 未结 9 1960
生来不讨喜
生来不讨喜 2020-12-23 10:54

I need a quick and easy way to store files with unique file names on iOS. I need to prefix the file with a string, and then append the generated unique identifier to the en

9条回答
  •  情书的邮戳
    2020-12-23 11:44

    Super-easy Swift 4 1-liner:

    fileName = "MyFileName_" + UUID().uuidString
    

    or

    fileName = "MyFileName_" + ProcessInfo().globallyUniqueString
    

提交回复
热议问题