Ben Beatles Levine
Ben Beatles Levine

Reputation: 153

Are UUID's, and the most basic level, just a string of unique characters?

I am currently learning about UUID in iOS, and of course I'm trying to make sense of them. From what I can gather, when you call NSUUID(), it returns a 128 bit string that is completely unique (though I'm not currently interested in how it can ensure a completely unique string, I figure it takes into account the date, time, and device identity). To make use of this string, you can append it to the end of the Document Directory (which I believe is unique to each application) to ensure a unique file path that can be used to access files later. Is this a correct understanding of the concept?

Upvotes: 0

Views: 173

Answers (2)

Wheelchair Geek
Wheelchair Geek

Reputation: 432

It depends on the version of Universally unique identifier. Version 4 is almost guaranteed to be unique but not completely. Wikipedia states the following:

"Out of a total of 128 bits, two bits indicate an RFC 4122 ("Leach-Salz") UUID and four bits the version (0100 indicating "randomly generated"), so randomly generated UUIDs have 122 random bits. The chance of two such UUIDs having the same value can be calculated using probability theory (birthday paradox). Using the approximation"

Reference: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29

Upvotes: 1

paulsm4
paulsm4

Reputation: 121649

Globally Unique Identifiers are 128-bit binary strings.

Microsoft COM uses them to prevent "name collisions" between components without needing some "central naming authority" (like we have for DNS names, IP addresses, broadcast frequencies, etc etc).

GUIDs are likely to be unique ... but it's not guaranteed.

Here is a good article explaining more:

And yes, your understanding of iOS NSUUIDs is exactly right:

Upvotes: 1

Related Questions