Mac Developer Library

Developer

CoreFoundation Framework Reference CFUUID Reference

Options
Deployment Target:

On This Page
Language:

CFUUID Reference

CFUUID objects are used by plug-ins to uniquely identify types, interfaces, and factories. When creating a new type, host developers must generate UUIDs to identify the type as well as its interfaces and factories.

UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values designed to be unique.

The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067. The hex representation looks, as you might expect, like a list of numerical values preceded by 0x. For example, 0x68, 0x75, 0x3A, 0x44, 0x4D, 0x6F, 0x12, 0x26, 0x9C, 0x60, 0x00, 0x50, 0xE4, 0xC0, 0x00, 0x67 . To use a UUID, you create it and then copy the resulting strings into your header and C language source files. Because a UUID is expressed as an array of bytes, there are no endianness considerations for different platforms.

You can create a CFUUID object using any one of the CFUUIDCreate... functions. Use the CFUUIDGetConstantUUIDWithBytes function if you want to declare a UUID constant in a #define statement. You can get the raw bytes of an existing CFUUID object using the CFUUIDGetUUIDBytes function.

Functions

  • Creates a Universally Unique Identifier (UUID) object.

    Declaration

    Swift

    func CFUUIDCreate(_ alloc: CFAllocator!) -> CFUUID!

    Objective-C

    CFUUIDRef CFUUIDCreate ( CFAllocatorRef alloc );

    Parameters

    alloc

    The allocator to use to allocate memory for the new CFUUID object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    Return Value

    A new CFUUID object. Ownership follows the The Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Creates a CFUUID object for a specified string.

    Declaration

    Swift

    func CFUUIDCreateFromString(_ alloc: CFAllocator!, _ uuidStr: CFString!) -> CFUUID!

    Objective-C

    CFUUIDRef CFUUIDCreateFromString ( CFAllocatorRef alloc, CFStringRef uuidStr );

    Parameters

    alloc

    The allocator to use to allocate memory for the new CFUUID object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    uuidStr

    A string containing a UUID. The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.

    Return Value

    A new CFUUID object, or if a CFUUID object of the same value already exists, the existing instance with its reference count incremented. Ownership follows the The Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Creates a CFUUID object from raw UUID bytes.

    Declaration

    Swift

    func CFUUIDCreateFromUUIDBytes(_ alloc: CFAllocator!, _ bytes: CFUUIDBytes) -> CFUUID!

    Objective-C

    CFUUIDRef CFUUIDCreateFromUUIDBytes ( CFAllocatorRef alloc, CFUUIDBytes bytes );

    Parameters

    alloc

    The allocator to use to allocate memory for the new CFUUID object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    bytes

    Raw UUID bytes to use to create the CFUUID object.

    Return Value

    A new CFUUID object. Ownership follows the The Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Creates a CFUUID object from raw UUID bytes.

    Declaration

    Swift

    func CFUUIDCreateWithBytes(_ alloc: CFAllocator!, _ byte0: UInt8, _ byte1: UInt8, _ byte2: UInt8, _ byte3: UInt8, _ byte4: UInt8, _ byte5: UInt8, _ byte6: UInt8, _ byte7: UInt8, _ byte8: UInt8, _ byte9: UInt8, _ byte10: UInt8, _ byte11: UInt8, _ byte12: UInt8, _ byte13: UInt8, _ byte14: UInt8, _ byte15: UInt8) -> CFUUID!

    Objective-C

    CFUUIDRef CFUUIDCreateWithBytes ( CFAllocatorRef alloc, UInt8 byte0, UInt8 byte1, UInt8 byte2, UInt8 byte3, UInt8 byte4, UInt8 byte5, UInt8 byte6, UInt8 byte7, UInt8 byte8, UInt8 byte9, UInt8 byte10, UInt8 byte11, UInt8 byte12, UInt8 byte13, UInt8 byte14, UInt8 byte15 );

    Parameters

    alloc

    The allocator to use to allocate memory for the new CFUUID object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    byte0

    Raw byte number 0.

    byte1

    Raw byte number 1.

    byte2

    Raw byte number 2.

    byte3

    Raw byte number 3.

    byte4

    Raw byte number 4.

    byte5

    Raw byte number 5.

    byte6

    Raw byte number 6.

    byte7

    Raw byte number 7.

    byte8

    Raw byte number 8.

    byte9

    Raw byte number 9.

    byte10

    Raw byte number 10.

    byte11

    Raw byte number 11.

    byte12

    Raw byte number 12.

    byte13

    Raw byte number 13.

    byte14

    Raw byte number 14.

    byte15

    Raw byte number 15.

    Return Value

    A new CFUUID object, or, if a CFUUID object of the same value already exists, the existing instance with its reference count incremented. Ownership follows the The Create Rule in Memory Management Programming Guide for Core Foundation.

    Discussion

    .

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the string representation of a specified CFUUID object.

    Declaration

    Swift

    func CFUUIDCreateString(_ alloc: CFAllocator!, _ uuid: CFUUID!) -> CFString!

    Objective-C

    CFStringRef CFUUIDCreateString ( CFAllocatorRef alloc, CFUUIDRef uuid );

    Parameters

    alloc

    The allocator to use to allocate memory for the new string. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    uuid

    The CFUUID object whose string representation to obtain.

    Return Value

    The string representation of uuid. Ownership follows the The Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns a CFUUID object from raw UUID bytes.

    Declaration

    Swift

    func CFUUIDGetConstantUUIDWithBytes(_ alloc: CFAllocator!, _ byte0: UInt8, _ byte1: UInt8, _ byte2: UInt8, _ byte3: UInt8, _ byte4: UInt8, _ byte5: UInt8, _ byte6: UInt8, _ byte7: UInt8, _ byte8: UInt8, _ byte9: UInt8, _ byte10: UInt8, _ byte11: UInt8, _ byte12: UInt8, _ byte13: UInt8, _ byte14: UInt8, _ byte15: UInt8) -> CFUUID!

    Objective-C

    CFUUIDRef CFUUIDGetConstantUUIDWithBytes ( CFAllocatorRef alloc, UInt8 byte0, UInt8 byte1, UInt8 byte2, UInt8 byte3, UInt8 byte4, UInt8 byte5, UInt8 byte6, UInt8 byte7, UInt8 byte8, UInt8 byte9, UInt8 byte10, UInt8 byte11, UInt8 byte12, UInt8 byte13, UInt8 byte14, UInt8 byte15 );

    Parameters

    alloc

    The allocator to use to allocate memory for the new CFUUID object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    byte0

    Raw byte number 0.

    byte1

    Raw byte number 1.

    byte2

    Raw byte number 2.

    byte3

    Raw byte number 3.

    byte4

    Raw byte number 4.

    byte5

    Raw byte number 5.

    byte6

    Raw byte number 6.

    byte7

    Raw byte number 7.

    byte8

    Raw byte number 8.

    byte9

    Raw byte number 9.

    byte10

    Raw byte number 10.

    byte11

    Raw byte number 11.

    byte12

    Raw byte number 12.

    byte13

    Raw byte number 13.

    byte14

    Raw byte number 14.

    byte15

    Raw byte number 15.

    Return Value

    A CFUUID object. Ownership follows the The Get Rule in Memory Management Programming Guide for Core Foundation.

    Discussion

    This function can be used in headers to declare a UUID constant with #define.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the value of a UUID object as raw bytes.

    Declaration

    Swift

    func CFUUIDGetUUIDBytes(_ uuid: CFUUID!) -> CFUUIDBytes

    Objective-C

    CFUUIDBytes CFUUIDGetUUIDBytes ( CFUUIDRef uuid );

    Parameters

    uuid

    The CFUUID object to examine.

    Return Value

    The value of uuid represented as raw bytes.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the type identifier for all CFUUID objects.

    Declaration

    Swift

    func CFUUIDGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFUUIDGetTypeID ( void );

    Return Value

    The type identifier for the CFUUID opaque type.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

Data Types

Miscellaneous

  • A 128-bit struct that represents a UUID as raw bytes.

    Declaration

    Swift

    struct CFUUIDBytes { var byte0: UInt8 var byte1: UInt8 var byte2: UInt8 var byte3: UInt8 var byte4: UInt8 var byte5: UInt8 var byte6: UInt8 var byte7: UInt8 var byte8: UInt8 var byte9: UInt8 var byte10: UInt8 var byte11: UInt8 var byte12: UInt8 var byte13: UInt8 var byte14: UInt8 var byte15: UInt8 }

    Objective-C

    typedef struct { UInt8 byte0; UInt8 byte1; UInt8 byte2; UInt8 byte3; UInt8 byte4; UInt8 byte5; UInt8 byte6; UInt8 byte7; UInt8 byte8; UInt8 byte9; UInt8 byte10; UInt8 byte11; UInt8 byte12; UInt8 byte13; UInt8 byte14; UInt8 byte15; } CFUUIDBytes;

    Fields

    byte0

    The first byte.

    byte1

    The second byte.

    byte2

    The third byte.

    byte3

    The fourth byte.

    byte4

    The fifth byte.

    byte5

    The sixth byte.

    byte6

    The seventh byte.

    byte7

    The eighth byte.

    byte8

    The ninth byte.

    byte9

    The tenth byte.

    byte10

    The eleventh byte.

    byte11

    The twelfth byte.

    byte12

    The thirteenth byte.

    byte13

    The fourteenth byte.

    byte14

    The fifteenth byte.

    byte15

    The sixteenth byte.

    Discussion

    This structure can be obtained from a CFUUID object using the CFUUIDGetUUIDBytes function. This structure can be passed to functions that expect a raw UUID.

    Availability

    Available in OS X v10.0 and later.

  • A reference to a CFUUID object.

    Declaration

    Swift

    typealias CFUUIDRef = CFUUID

    Objective-C

    typedef const struct __CFUUID *CFUUIDRef;

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.