Home > Net >  UUID is unique for global? like swift, Android, and java
UUID is unique for global? like swift, Android, and java

Time:11-18

Actually I had a doubt reg. UUID().uuidString is unique for globally like Android, iOS Swift, java and etc.

UUID is like 9297EEEF-FE6D-4758-88BF-4051961B8619

am generating unique id for each record in internal Database and for api callings. Same thing other teams(android and web) doing. Is that any possible for duplication?

CodePudding user response:

UUID().uuidString generates a random UUID string - that is, a string with random digits and characters that fulfils the UUID v4 spec. This string is a completely random string and has nothing to do with the OS it is generated on. Here is a website that generates random UUIDs.

However, due to its random nature, there is a tiny tiny chance that you'll get a duplicate UUID (whether on the same platform or another. This chance is so tiny, it's basically negligible.

Think of UUID v4 as being a very long random number that can be easily identified as a UUID at a glance.

CodePudding user response:

I think so, So, planned to add some params like static text, and date, time with seconds.

String(format: "%@-IOS-%@", UUID().uuidString, Date().toString(format: "ddMMyyyyHHmmss"))

So, I think duplication percentage will reduce.

My result like:

9297EEEF-FE6D-4758-88BF-4051961B8619-IOS-17112022153206

  • Related