AppleCFObject - UBogun/Xojo-iosLib GitHub Wiki

Inherits from ./.
Memory leak check: n/a
Status: complete

Many core classes used by Apple that come in NS… shape like NSArray, NSColor have their Core Foundation counterparts. Often these classes are even interchangeable with their counterparts, see tollfree bridging in Apple's docs, which means you can use for example the CFArray methods on the same id Ptr you use the NSArray methods.
Core Foundation objects were not built as object classes. Usually only the ptr – the CFTypeRef – is handled and appropriate external methods are cast on this.
The main pluspoint of CFObjects is that their methods are usually faster, but often a bit more complicated to call or read. That's why I created them as Object classes too and built computed properties around them so you can use their speed but don't have to find the correct external methods for them.
In some cases you will want to create a method that takes either a NSObject or a CFObject as parameter. For this purpose please have a look at the iOSLibGeneralObject Interface class.

iOSLibCFObject is the core class of CFObject subclasses. You will usually not want to create a CFObject only but use on of the subclasses. Therefore there is no real constructor for this class.

Constructor

Constructor (aTypeRef as Ptr): For iOS methods that return a CFObject subclass.

Properties

CFTypeDescription As Text (read-only): Gives you the text represenation of the CFObject's class.

CFTypeRef As Ptr (read-only): The object ptr itself, much like ID on the NSObject class.

Description As Text (read-only): A Text great for debugging purposes giving information on the object.

Hash As UInteger (read-only): A hash value for the Object.

HasOwnerShip As Boolean (read-only): A helper property to keep track of CFObjects that were created by the application so releasing the Object works reliable.

isNIL As Boolean (read-only): Returns true if the object is NIL instead.

RetainCount As Integer (read-only): The number of times this object was retained (is owned by other properties). Please note that CFObject memory managment works a bit different than NSObject management – CFObjects as result of API methods need to be retained too. (The class will take care for that).

TypeID As UInteger (read-only): The ClassPtr of a CFObject.

Methods

Equals (AnotherCFObject AS CFObject) As Boolean: True if both have the same properties.

PrintInDebugLog(): Prints the Description to console.