Search code examples
swiftuuidfoundation

Does Swift Foundation's UUID incorporate the time by default?


Does the Swift UUID type take into account the time it was created to help guarantee its uniqueness or is it purely random? If not, is there a version that does?


Solution

  • I quote the documentation:

    Initializes a new UUID with RFC 4122 version 4 random bytes.

    So it is entirely random. There is a post already describing how to create the time based UUID over here.