AppleObject - UBogun/Xojo-iosLib GitHub Wiki
Inherits from ./.
Memory leak check passed
Status: Fairly complete. A few initializers and similar methods, performSelectors and ResolveMethods missing.
This is an implementation of NSObject, the core class of objects in iOS. In most cases you will not use AppleObject directly but one of its subclasses.
Constructor
Constructor(): Creates a new iOSObject.
Constructor (anId As Ptr): The constructor for receiving objects from system methods.
Properties
ClassName As CString (read-only): The internal name of the class.
Class_ As Ptr (read-only): A ptr to the instance's class. Mind the underscore!
DebugDescription As Text (read-only): A string very useful for debug purposes. Tells you debug details about the object. In many cases, it is enough to inspect this property to gain insight on the object's settings.
Hash As UInteger (read-only): A hash value for the object.
HasOwnership As Boolean (read-only): This flag is internally set when iOSLib creates an iOS class. It is evaluated in the destructor to relase memory for self-created objects.
Id As Ptr (read-only): The ptr to the object itself, in Xojo terms: The handle of the object.
isNIL As Boolean (read-only): It would be great if you could check an iOS object for being NIL when returned from a system function. Sadly, you can't: The cunstructor will always return the Xojo base structure of the object. Instead of checking a retuned iOLibObject for being NIL, you should check this property. It returns true when ID is NIL.
isProxy As Boolean (read-only): True if the object's class does not inherit from NSObject. Useful, of course, rather in other classes where this property should be added.
MetaClass As Ptr (read-only): A ptr to the object's class' metaclass.
MetaClassName As CString (read-only): The name of the property above.
RetainCount As UInteger (read-only): The ARC count of the object. Useful for debugging. A RetainCount of 0 should make you nervous on an existing object – it means the object can get out of scope anytime. RetainCount is increased by casting Retain on ID and lowered by Release. But you should not tamper with it if you do not create own iOS Object implementations.
SuperClass As Ptr (read-only): A ptr to the object's class' superclass.
SuperClassName As CString (read-only): The name of the property above.
Methods
AutoRelease(): Like a delayed Release call: The retaincount will be reduced by 1 when the Autorelease pool the object belongs to casts a release on its so-tagged children. _You will usually not call this method directly, only in custom controls and iOSUserControls.
CancelsPreviousPerformRequests(): Cancels delayed PerformSelector requests of the object that have not yet been called.
CGAffineTransformValueForKey (Key As CFStringRef) As CGAffineTransform: Used for Key Value Coding, an Apple way of retrieving values of an object by sending the values' names to it. This method returns a CGAffineTransform structure.
ClassMethodImplementation (Aselector As Ptr / CFStringRef) As Ptr: Returns a Ptr to the implementation of an object's class method or NIL if there is none.
ConformsToProtocol (AProtocol As Ptr / AppleProtocol) As Boolean: Returns True if the object supports the features of a selected protocol.
Copy() As iOSObject: Returns a copy of the object.
Equals (AnotherObject As AppleObject / Ptr) As Boolean: Returns True if both objects are identical.
GeneralID As Ptr (read-only): Part of the AppleGeneralObject Protocol which combines Foundation and CoreFoundation objects. Returns their individual ID or CFTypeRef ptr – in this case ID.
InstanceMethodImplementation (Aselector As Ptr / CFStringRef) As Ptr: Returns a Ptr to the implementation of an object's instance method or NIL if there is none.
IsKindOfClass (aClass As Ptr) As Boolean: True of the object is an instance of given class or an instance of any class that inherits from that class.
IsMemberOfClass (aClass As Ptr) As Boolean: True if the object is an instance of given class.
IsSubclassOfClass (aClass As Ptr) As Boolean: True if the object is a subclass of, or identical to, a given class.
MethodSignature (ASelector As Ptr / CFStringRef) As AppleMethodSignature: Returns the method signature of a selector.
MutableArrayForKey (Key A CFStringRef) As AppleMutableArray: Used for Key Value Coding, an Apple way of retrieving values of an object by sending the values' names to it. This method returns a mutable Array.
MutableArrayForKeyPath (Key A CFStringRef) As AppleMutableArray: Like above, but in this case you can pass a keypath, which means a dot-separated string defining the exact key in its hierarchy.
MutableCopy() As AppleObject: Returns a mutable copy of the object.
PerformSelector (ASelector As Ptr / CFStringRef, opt. anObject As AppleObject, opt. AnotherObject As AppleObject) As Ptr: Calls an instance method with two optional parameter objects and returns the result as a Ptr.
PerformSelector (ASelector As Ptr / CFStringRef, delay as double, opt. anObject As AppleObject): Calls an instance method after delay seconds. Has no return value but an optional object parameter.
PerformSelector (aSelector As Ptr / CFStringRef, opt. anObject As AppleObject, waituntilDone As Boolean): Calls an instance method with an optional Parameter as Appleobject, waiting for completion if WaltUntilDone = True. Has no return value.
PerformSelectorInBackground (aSelector As Ptr / CFStringRef, opt. anObject As AppleObject): Calls an instance method on a background thread. Has no return value.
Release(): Lowers the object's RetainCount by 1. You will usually not call this method. It is needed for the instance's destructor to avoid memory leaks.
RespondsToSelector (Selector As Ptr / CFStringRef) As Boolean: Returns True if the object knows to handle the selector; in other words, has this method.
Retain(): Increases the object's RetainCount by 1. Do not mess with this method unless you know what you are doing. You might cause memory leaks.
SetCGAffineTransformForKey (Key As CFStringRef, Value As CGAffineTransform): Part of Apple's Key value coding. Allows you to set an object property with a known name that has a CGAffineTransform value.
SetNilValueForKey (Key As CFStringRef): Again part of KVC. Use this to set a object property to NIL.
SetValueForKey (Key As CFStringRef, Value As AppleGeneralObject): As above, but now for any AppleGeneralObject as parameter.
SetValueForKeyPath (Key As CFStringRef, Value As AppleGeneralObject): As above, but now for a keyPath, which means the dot-separated hierarchy of the property.
SuperClassMethodImplementation (ASelector As Ptr / CFStringRef) As Ptr: Returns the Superclass' implementation of a selector. Seems to be 32bit only, caused problems on 64bit builds!
ValueForKey (Key As CFStringRef) As Ptr: Part of Key Value Coding again. Returns a ptr for a key which you can transform to the class it should be by using the MakeFromPtr shared method of the class.
ValueForKeyPath (KeyPath As CFStringRef): As above, but for a full key path.
ValueKeyDictionary (Keys As AppleArray Of CFStringRef) As AppleDictionary: Returns a dictionary for all the keys you defined in the array.
##Shared Properties ClassAvailable As Boolean (read-only): Useful for subclasses which are not included in all of the supported iOS versions. Returns true if the class exists on the device, which means, the iOS version supports the class.
ClassPtr As Ptr: The custom or iOS system class ptr for the class.
##Shared Methods Alloc (AClass As Ptr) As Ptr: Used to allocate memory for an object. If you do not create your own declared classes, you will not need this method.
AppearanceWhenContainedIn (ParamArray Classes() As Ptr) As AppleObject: Useful for view subclasses. Returns the appearance object which you can modify that is only valid if the object is contained in of the classes you defined. Deprecated in iOS 9!
MakeFromPtr (aPtr as Ptr) As AppleObject: Returns the AppleObject from a ptr.
MethodSignatureForSelector (aSelector As Ptr / CFStringRef) As AppleMethodsignature: Returns the instance's method signature for a given selector.