Search code examples
objective-cuuid

How to store UUID as int


I'm having some issues here. I am using the following code to generate the UUID in my application.

- (NSString *)GetUUID {
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID);
    CFRelease(theUUID);
    return [(NSString *)string autorelease];
}

This code returns an NSString object back. Now I want to store the generated UUID as unsigned int. Any suggestions on how can I do it here?


Solution

  • According to the Wikipedia page, UUIDs are 128 bits long. The largest int value you'll be able to work with is 64 bits. Therefore, I'd says you can't store it in an int because there simply isn't room.