Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Generating a UUID Programmatically
Listing 1 shows you how to generate a UUID programmatically using CFUUID functions. Plug-ins use UUIDs to uniquely identify types, interfaces, and factories.
Listing 1 Generating a UUID programmatically
CFUUIDRef myUUID; |
CFStringRef myUUIDString; |
char strBuffer[100]; |
myUUID = CFUUIDCreate(kCFAllocatorDefault); |
myUUIDString = CFUUIDCreateString(kCFAllocatorDefault, myUUID); |
// This is the safest way to obtain a C string from a CFString. |
CFStringGetCString(myUUIDString, strBuffer, 100, kCFStringEncodingASCII); |
CFStringRef outputString = |
CFStringCreateWithFormat(kCFAllocatorDefault, |
NULL, |
CFSTR("My UUID is: %s!\n"), |
strBuffer); |
CFShow(outputString); |
Copyright © 2003, 2005 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2005-03-03