Is there a method to generate a standard 128bit GUID (UUID) on the Mac?

Lawrence Johnston picture Lawrence Johnston · Nov 15, 2008 · Viewed 19.8k times · Source

Is there a built in function equivalent to .NET's

Guid.NewGuid();

in Cocoa?

My desire is to produce a string along the lines of 550e8400-e29b-41d4-a716-446655440000 which represents a unique identifier.

Answer

Jörg W Mittag picture Jörg W Mittag · Nov 15, 2008

UUIDs are handled in Core Foundation, by the CFUUID library. The function you are looking for is CFUUIDCreate.

FYI for further searches: these are most commonly known as UUIDs, the term GUID isn't used very often outside of the Microsoft world. You might have more luck with that search term.