Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - generate one time UUID

In swift, this code generate a random uuid...

let uuid = UUID().uuidString

I have it so when I click on a button, it gets the uuid and prints it to the console, however, when I click the button once more, I get a different uuid. I want to be able to save the UUID that I get on the first click of the button to a string... Is that possible? Thanks!

like image 917
adam eliezerov Avatar asked Feb 23 '17 11:02

adam eliezerov


1 Answers

UUID is always return value.

If you want to only one time for your application, then you have to stored into iPhone Keychain. Check out Keychain tutorial.

Follow the steps to to stored into Keychain: 1) Get data from Keychain.

2) If you don't get data then generate new UUID and stored into Keychain and use it.

3) If you get UUID then directly use it.

You can kaychain demo and demo

like image 96
Nirmalsinh Rathod Avatar answered Sep 24 '22 02:09

Nirmalsinh Rathod