How to compare two CFUUIDs (Mac OS X Carbon / CoreFoundation)?

How to compare two CFUUIDRefwith CoreFoundation Carbon base in Mac OS X? Is there an easier way to check if two CFUUIDs are equal, except convert them to strings, and then compare them?

+3
source share
2 answers

A CFUUID is a kind of CFType , so you would use the same CFEqual function that you use for any other CF objects.

+9
source

I'm not sure if there is a canonical or recommended method as such, but is that enough?

#define CompareUUIDs(u1, u2) memcmp(CFUUIDGetUUIDBytes(u1), CFUUIDGetUUIDBytes(u2))

It will be used as follows:

if (CompareUUIDs(u1, u2) == 0) {
    // UUIDs are equal
} // etc..

, , :

#define UUIDsAreEqual(u1, u2) (memcmp(CFUUIDGetUUIDBytes(u1), CFUUIDGetUUIDBytes(u2)) == 0)

:

if (UUIDsAreEqual(u1, u2)) {
    // UUIDs are equal
} // etc..
+1

Source: https://habr.com/ru/post/1788893/


All Articles