How to check if an object is NSObject or CFTypeRef

Discussion in 'iOS Programming' started by namanhams, Aug 1, 2012.

  1. macrumors regular

    Joined:
    Jun 3, 2009
    #1
    I have an object of type (id). This object is either a ABRecordRef, or an instance of a class that is subclass of NSObject.

    How do i determine the real type of this object ?
    Thanks.
     
  2. macrumors member

    Joined:
    Apr 20, 2012
    #2
    I'd say look into these three
    isa field
    isKindOfClass
    respondsToSelector
     
  3. macrumors 68000

    Reason077

    Joined:
    Aug 14, 2007
    #3
    ABRecordRef is a C type - it should not be stored in the ObjC type "id"!

    Normally, if you want to test if an ObjC object is a particular class, you do it like the following:

    "if ([obj isKindOfClass: [MyObjCClass class]]) ..."

    But again, you should not be calling isKindOfClass (or any other ObjC method) on an instance of ABRecordRef - it is not an ObjC type.
     

Share This Page