objective-ccore-foundation

Core Foundation respective for isKindOfClass?


Is there any CoreFoundation handy way for checking a class's pedigree like isKindOfClass?


Solution

  • Since CoreFoundation is based on "opaque" references, it is difficult to inspect unknown objects. There is no isa-pointer like with a normal objective-c class which you can look at in order to find out about the type of an arbitrary object. However, CF has some functions to offer that can help you: specifically, CFGetTypeID():

    CFTypeID type = CFGetTypeID(anObject); 
    if (CFArrayGetTypeID() == type)
        printf("anObject is an array.");
    else
        printf("anObject is NOT an array.");
    

    See CFType Reference.