Class ObjCRuntime
- java.lang.Object
-
- org.lwjgl.system.macosx.ObjCRuntime
-
public class ObjCRuntime extends java.lang.ObjectNative bindings to the Objective-C Runtime.Due to the nature of the
objc_msgSend*functions, they are not directly exposed in this binding. Advanced users with good understanding of the complexity involved with using these functions, may access them via theObjCRuntime.getLibrary()method:SharedLibrary objc = ObjCRuntime.getLibrary(); long objc_msgSend = objc.getFunctionAddress("objc_msgSend"); // example usage long NSThread = objc_getClass("NSThread"); long currentThread = invokePPP(objc_msgSend, NSThread, sel_getUid("currentThread"));The safe way to use objc_msgSend in C code is to cast it to an appropriate function pointer. This is exactly what the
JNIclass does. If a particular function signature is not available,DynCallmay be used to invoke it.The functions not exposed are:
- objc_msgSend
- objc_msgSend_stret
- objc_msgSendSuper
- objc_msgSendSuper_stret
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classObjCRuntime.FunctionsContains the function pointers loaded from the objcSharedLibrary.
-
Field Summary
Fields Modifier and Type Field and Description static char_C_ARY_B
_C_ARY_E
_C_ATOM
_C_BFLD
_C_BOOL
_C_CHARPTR
_C_CHR
_C_CLASS
_C_CONST
_C_DBL
_C_FLT
_C_ID
_C_INT
_C_LNG
_C_LNG_LNG
_C_PTR
_C_SEL
_C_SHT
_C_STRUCT_B
_C_STRUCT_E
_C_UCHR
_C_UINT
_C_ULNG
_C_ULNG_LNG
_C_UNDEF
_C_UNION_B
_C_UNION_E
_C_USHT
_C_VECTOR
_C_VOIDTypes.static longnilNil value.static byteNOBoolean values.static intOBJC_ASSOCIATION_ASSIGN
OBJC_ASSOCIATION_COPY
OBJC_ASSOCIATION_COPY_NONATOMIC
OBJC_ASSOCIATION_RETAIN
OBJC_ASSOCIATION_RETAIN_NONATOMICPolicies related to associative references.static byteYESBoolean values.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static booleanclass_addIvar(long cls, java.nio.ByteBuffer name, long size, byte alignment, java.nio.ByteBuffer types)Adds a new instance variable to a class.static booleanclass_addIvar(long cls, java.lang.CharSequence name, long size, byte alignment, java.lang.CharSequence types)Adds a new instance variable to a class.static booleanclass_addMethod(long cls, long name, long imp, java.nio.ByteBuffer types)Adds a new method to a class with a given name and implementation.static booleanclass_addMethod(long cls, long name, long imp, java.lang.CharSequence types)Adds a new method to a class with a given name and implementation.static booleanclass_addProperty(long cls, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes)Adds a property to a class.static booleanclass_addProperty(long cls, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes)Adds a property to a class.static booleanclass_addProtocol(long cls, long protocol)Adds a protocol to a class.static booleanclass_conformsToProtocol(long cls, long protocol)Returns a Boolean value that indicates whether a class conforms to a given protocol.static PointerBufferclass_copyIvarList(long cls)Describes the instance variables declared by a class.static PointerBufferclass_copyMethodList(long cls)Describes the instance methods implemented by a class.static PointerBufferclass_copyPropertyList(long cls)Describes the properties declared by a class.static PointerBufferclass_copyProtocolList(long cls)Describes the protocols adopted by a class.static longclass_createInstance(long cls, long extraBytes)Creates an instance of a class, allocating memory for the class in the default malloc memory zone.static longclass_getClassMethod(long cls, long name)Returns a pointer to the data structure describing a given class method for a given class.static longclass_getClassVariable(long cls, java.nio.ByteBuffer name)Returns the Ivar for a specified class variable of a given class.static longclass_getClassVariable(long cls, java.lang.CharSequence name)Returns the Ivar for a specified class variable of a given class.static java.lang.Stringclass_getImageName(long cls)Returns the name of the dynamic library a class originated from.static longclass_getInstanceMethod(long cls, long name)Returns a specified instance method for a given class.static longclass_getInstanceSize(long cls)Returns the size of instances of a class.static longclass_getInstanceVariable(long cls, java.nio.ByteBuffer name)Returns the Ivar for a specified instance variable of a given class.static longclass_getInstanceVariable(long cls, java.lang.CharSequence name)Returns the Ivar for a specified instance variable of a given class.static java.lang.Stringclass_getIvarLayout(long cls)Returns a description of the Ivar layout for a given class.static longclass_getMethodImplementation(long cls, long name)Returns the function pointer that would be called if a particular message were sent to an instance of a class.static java.lang.Stringclass_getName(long cls)Returns the name of a class.static longclass_getProperty(long cls, java.nio.ByteBuffer name)Returns a property with a given name of a given class.static longclass_getProperty(long cls, java.lang.CharSequence name)Returns a property with a given name of a given class.static longclass_getSuperclass(long cls)Returns the superclass of a class.static intclass_getVersion(long cls)Returns the version number of a class definition.static java.lang.Stringclass_getWeakIvarLayout(long cls)Returns a description of the layout of weak Ivars for a given class.static booleanclass_isMetaClass(long cls)Returns a Boolean value that indicates whether a class object is a metaclass.static longclass_replaceMethod(long cls, long name, long imp, java.nio.ByteBuffer types)Replaces the implementation of a method for a given class.static longclass_replaceMethod(long cls, long name, long imp, java.lang.CharSequence types)Replaces the implementation of a method for a given class.static voidclass_replaceProperty(long cls, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes)Replaces a property of a class.static voidclass_replaceProperty(long cls, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes)Replaces a property of a class.static booleanclass_respondsToSelector(long cls, long name)Returns a Boolean value that indicates whether instances of a class respond to a particular selector.static voidclass_setIvarLayout(long cls, java.nio.ByteBuffer layout)Sets the Ivar layout for a given class.static voidclass_setIvarLayout(long cls, java.lang.CharSequence layout)Sets the Ivar layout for a given class.static voidclass_setVersion(long cls, int version)Sets the version number of a class definition.static voidclass_setWeakIvarLayout(long cls, java.nio.ByteBuffer layout)Sets the layout for weak Ivars for a given class.static voidclass_setWeakIvarLayout(long cls, java.lang.CharSequence layout)Sets the layout for weak Ivars for a given class.static SharedLibrarygetLibrary()Returns the objcSharedLibrary.static longimp_getBlock(long anImp)Returns the block associated with an IMP that was created usingObjCRuntime.imp_implementationWithBlock(long).static longimp_implementationWithBlock(long block)Creates a pointer to a function that calls the specified block when the method is called.static booleanimp_removeBlock(long anImp)Disassociates a block from an IMP that was created usingObjCRuntime.imp_implementationWithBlock(long), and releases the copy of the block that was created.static java.lang.Stringivar_getName(long v)Returns the name of an instance variable.static longivar_getOffset(long v)Returns the offset of an instance variable.static java.lang.Stringivar_getTypeEncoding(long v)Returns the type string of an instance variable.static java.lang.Stringmethod_copyArgumentType(long m, int index)Returns a string describing a single parameter type of a method.static java.lang.Stringmethod_copyReturnType(long m)Returns a string describing a method's return type.static voidmethod_exchangeImplementations(long m1, long m2)Exchanges the implementations of two methods.static voidmethod_getArgumentType(long m, int index, java.nio.ByteBuffer dst)Returns by reference a string describing a single parameter type of a method.static java.lang.Stringmethod_getArgumentType(long m, int index, long dst_len)Returns by reference a string describing a single parameter type of a method.static longmethod_getImplementation(long m)Returns the implementation of a method.static longmethod_getName(long m)Returns the name of a method.static intmethod_getNumberOfArguments(long m)Returns the number of arguments accepted by a method.static voidmethod_getReturnType(long m, java.nio.ByteBuffer dst)Returns by reference a string describing a method's return type.static java.lang.Stringmethod_getReturnType(long m, long dst_len)Returns by reference a string describing a method's return type.static java.lang.Stringmethod_getTypeEncoding(long m)Returns a string describing a method's parameter and return types.static longmethod_setImplementation(long m, long imp)Sets the implementation of a method.static longobjc_allocateClassPair(long superclass, java.nio.ByteBuffer name, long extraBytes)Creates a new class and metaclass.static longobjc_allocateClassPair(long superclass, java.lang.CharSequence name, long extraBytes)Creates a new class and metaclass.static longobjc_allocateProtocol(java.nio.ByteBuffer name)Creates a new protocol instance.static longobjc_allocateProtocol(java.lang.CharSequence name)Creates a new protocol instance.static longobjc_constructInstance(long cls, java.nio.ByteBuffer bytes)Creates an instance of a class at the specified location.static PointerBufferobjc_copyClassList()Creates and returns a list of pointers to all registered class definitions.static PointerBufferobjc_copyClassNamesForImage(java.nio.ByteBuffer image)Returns the names of all the classes within a specified library or framework.static PointerBufferobjc_copyClassNamesForImage(java.lang.CharSequence image)Returns the names of all the classes within a specified library or framework.static PointerBufferobjc_copyImageNames()Returns the names of all the loaded Objective-C frameworks and dynamic libraries.static PointerBufferobjc_copyProtocolList()Returns an array of all the protocols known to the runtime.static longobjc_destructInstance(long obj)Destroys an instance of a class without freeing memory and removes any of its associated references.static voidobjc_disposeClassPair(long cls)Destroys a class and its associated metaclass.static voidobjc_enumerationMutation(long obj)Inserted by the compiler when a mutation is detected during a foreach iteration.static longobjc_getAssociatedObject(long object, long key)Returns the value associated with a given object for a given key.static longobjc_getClass(java.nio.ByteBuffer name)Returns the class definition of a specified class.static longobjc_getClass(java.lang.CharSequence name)Returns the class definition of a specified class.static intobjc_getClassList(PointerBuffer buffer)Obtains the list of registered class definitions.static longobjc_getMetaClass(java.nio.ByteBuffer name)Returns the metaclass definition of a specified class.static longobjc_getMetaClass(java.lang.CharSequence name)Returns the metaclass definition of a specified class.static longobjc_getProtocol(java.nio.ByteBuffer name)Returns a specified protocol.static longobjc_getProtocol(java.lang.CharSequence name)Returns a specified protocol.static longobjc_getRequiredClass(java.nio.ByteBuffer name)Returns the class definition of a specified class.static longobjc_getRequiredClass(java.lang.CharSequence name)Returns the class definition of a specified class.static longobjc_loadWeak(PointerBuffer location)Loads the object referenced by a weak pointer and returns it.static longobjc_lookUpClass(java.nio.ByteBuffer name)Returns the class definition of a specified class.static longobjc_lookUpClass(java.lang.CharSequence name)Returns the class definition of a specified class.static voidobjc_registerClassPair(long cls)Registers a class that was allocated usingObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long).static voidobjc_registerProtocol(long proto)Registers a newly created protocol with the Objective-C runtime.static voidobjc_removeAssociatedObjects(long object)Removes all associations for a given object.static voidobjc_setAssociatedObject(long object, long key, long value, long policy)Sets an associated value for a given object using a given key and association policy.static voidobjc_setEnumerationMutationHandler(EnumerationMutationHandlerI handler)Sets the current mutation handler.static longobjc_storeWeak(PointerBuffer location, long obj)Stores a new value in a__weakvariable.static longobject_copy(long obj, long size)Returns a copy of a given object.static longobject_dispose(long obj)Frees the memory occupied by a given object.static longobject_getClass(long obj)Returns the class of an object.static java.lang.Stringobject_getClassName(long obj)Returns the class name of a given object.static longobject_getIndexedIvars(long obj)This function returns a pointer to any extra bytes allocated with the instance (as specified byObjCRuntime.class_createInstance(long, long)with extraBytes>0).static longobject_getInstanceVariable(long obj, java.nio.ByteBuffer name, PointerBuffer outValue)Obtains the value of an instance variable of a class instance.static longobject_getInstanceVariable(long obj, java.lang.CharSequence name, PointerBuffer outValue)Obtains the value of an instance variable of a class instance.static longobject_getIvar(long obj, long ivar)Reads the value of an instance variable in an object.static longobject_setClass(long obj, long cls)Sets the class of an object.static longobject_setInstanceVariable(long obj, java.nio.ByteBuffer name, java.nio.ByteBuffer value)Changes the value of an instance variable of a class instance.static longobject_setInstanceVariable(long obj, java.lang.CharSequence name, java.nio.ByteBuffer value)Changes the value of an instance variable of a class instance.static voidobject_setIvar(long obj, long ivar, long value)Sets the value of an instance variable in an object.static ObjCPropertyAttribute.Bufferproperty_copyAttributeList(long property)Returns an array of property attributes for a given property.static java.lang.Stringproperty_copyAttributeValue(long property, java.nio.ByteBuffer attributeName)Returns the value of a property attribute given the attribute name.static java.lang.Stringproperty_copyAttributeValue(long property, java.lang.CharSequence attributeName)Returns the value of a property attribute given the attribute name.static java.lang.Stringproperty_getAttributes(long property)Returns the attribute string of a property.static java.lang.Stringproperty_getName(long property)Returns the name of a property.static voidprotocol_addMethodDescription(long proto, long name, java.nio.ByteBuffer types, boolean isRequiredMethod, boolean isInstanceMethod)Adds a method to a protocol.static voidprotocol_addMethodDescription(long proto, long name, java.lang.CharSequence types, boolean isRequiredMethod, boolean isInstanceMethod)Adds a method to a protocol.static voidprotocol_addProperty(long proto, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty)Adds a property to a protocol that is under construction.static voidprotocol_addProperty(long proto, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty)Adds a property to a protocol that is under construction.static voidprotocol_addProtocol(long proto, long addition)Adds a registered protocol to another protocol that is under construction.static booleanprotocol_conformsToProtocol(long proto, long other)Returns a Boolean value that indicates whether one protocol conforms to another protocol.static ObjCMethodDescription.Bufferprotocol_copyMethodDescriptionList(long p, boolean isRequiredMethod, boolean isInstanceMethod)Returns an array of method descriptions of methods meeting a given specification for a given protocol.static PointerBufferprotocol_copyPropertyList(long proto)Returns an array of the properties declared by a protocol.static PointerBufferprotocol_copyProtocolList(long proto)eturns an array of the protocols adopted by a protocol.static ObjCMethodDescriptionprotocol_getMethodDescription(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, ObjCMethodDescription __result)Returns a method description structure for a specified method of a given protocol.static java.lang.Stringprotocol_getName(long p)Returns a the name of a protocol.static longprotocol_getProperty(long proto, java.nio.ByteBuffer name, boolean isRequiredProperty, boolean isInstanceProperty)Returns the specified property of a given protocol.static longprotocol_getProperty(long proto, java.lang.CharSequence name, boolean isRequiredProperty, boolean isInstanceProperty)Returns the specified property of a given protocol.static booleanprotocol_isEqual(long proto, long other)Returns a Boolean value that indicates whether two protocols are equal.static java.lang.Stringsel_getName(long sel)Returns the name of the method specified by a given selector.static longsel_getUid(java.nio.ByteBuffer str)Registers a method name with the Objective-C runtime system.static longsel_getUid(java.lang.CharSequence str)Registers a method name with the Objective-C runtime system.static booleansel_isEqual(long lhs, long rhs)Returns a Boolean value that indicates whether two selectors are equal.static longsel_registerName(java.nio.ByteBuffer str)Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.static longsel_registerName(java.lang.CharSequence str)Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.
-
-
-
Field Detail
-
nil
public static final long nil
Nil value.- See Also:
- Constant Field Values
-
YES
public static final byte YES
Boolean values.- See Also:
- Constant Field Values
-
NO
public static final byte NO
Boolean values.- See Also:
- Constant Field Values
-
_C_ID
public static final char _C_ID
Types.- See Also:
- Constant Field Values
-
_C_CLASS
public static final char _C_CLASS
Types.- See Also:
- Constant Field Values
-
_C_SEL
public static final char _C_SEL
Types.- See Also:
- Constant Field Values
-
_C_CHR
public static final char _C_CHR
Types.- See Also:
- Constant Field Values
-
_C_UCHR
public static final char _C_UCHR
Types.- See Also:
- Constant Field Values
-
_C_SHT
public static final char _C_SHT
Types.- See Also:
- Constant Field Values
-
_C_USHT
public static final char _C_USHT
Types.- See Also:
- Constant Field Values
-
_C_INT
public static final char _C_INT
Types.- See Also:
- Constant Field Values
-
_C_UINT
public static final char _C_UINT
Types.- See Also:
- Constant Field Values
-
_C_LNG
public static final char _C_LNG
Types.- See Also:
- Constant Field Values
-
_C_ULNG
public static final char _C_ULNG
Types.- See Also:
- Constant Field Values
-
_C_LNG_LNG
public static final char _C_LNG_LNG
Types.- See Also:
- Constant Field Values
-
_C_ULNG_LNG
public static final char _C_ULNG_LNG
Types.- See Also:
- Constant Field Values
-
_C_FLT
public static final char _C_FLT
Types.- See Also:
- Constant Field Values
-
_C_DBL
public static final char _C_DBL
Types.- See Also:
- Constant Field Values
-
_C_BFLD
public static final char _C_BFLD
Types.- See Also:
- Constant Field Values
-
_C_BOOL
public static final char _C_BOOL
Types.- See Also:
- Constant Field Values
-
_C_VOID
public static final char _C_VOID
Types.- See Also:
- Constant Field Values
-
_C_UNDEF
public static final char _C_UNDEF
Types.- See Also:
- Constant Field Values
-
_C_PTR
public static final char _C_PTR
Types.- See Also:
- Constant Field Values
-
_C_CHARPTR
public static final char _C_CHARPTR
Types.- See Also:
- Constant Field Values
-
_C_ATOM
public static final char _C_ATOM
Types.- See Also:
- Constant Field Values
-
_C_ARY_B
public static final char _C_ARY_B
Types.- See Also:
- Constant Field Values
-
_C_ARY_E
public static final char _C_ARY_E
Types.- See Also:
- Constant Field Values
-
_C_UNION_B
public static final char _C_UNION_B
Types.- See Also:
- Constant Field Values
-
_C_UNION_E
public static final char _C_UNION_E
Types.- See Also:
- Constant Field Values
-
_C_STRUCT_B
public static final char _C_STRUCT_B
Types.- See Also:
- Constant Field Values
-
_C_STRUCT_E
public static final char _C_STRUCT_E
Types.- See Also:
- Constant Field Values
-
_C_VECTOR
public static final char _C_VECTOR
Types.- See Also:
- Constant Field Values
-
_C_CONST
public static final char _C_CONST
Types.- See Also:
- Constant Field Values
-
OBJC_ASSOCIATION_ASSIGN
public static final int OBJC_ASSOCIATION_ASSIGN
Policies related to associative references.- See Also:
- Constant Field Values
-
OBJC_ASSOCIATION_RETAIN_NONATOMIC
public static final int OBJC_ASSOCIATION_RETAIN_NONATOMIC
Policies related to associative references.- See Also:
- Constant Field Values
-
OBJC_ASSOCIATION_COPY_NONATOMIC
public static final int OBJC_ASSOCIATION_COPY_NONATOMIC
Policies related to associative references.- See Also:
- Constant Field Values
-
OBJC_ASSOCIATION_RETAIN
public static final int OBJC_ASSOCIATION_RETAIN
Policies related to associative references.- See Also:
- Constant Field Values
-
OBJC_ASSOCIATION_COPY
public static final int OBJC_ASSOCIATION_COPY
Policies related to associative references.- See Also:
- Constant Field Values
-
-
Method Detail
-
getLibrary
public static SharedLibrary getLibrary()
Returns the objcSharedLibrary.
-
object_copy
public static long object_copy(long obj, long size)Returns a copy of a given object.- Parameters:
obj- an Objective-C objectsize- the size of the objectobj- Returns:
- a copy of obj
-
object_dispose
public static long object_dispose(long obj)
Frees the memory occupied by a given object.- Parameters:
obj- an Objective-C object- Returns:
ObjCRuntime.nil
-
object_getClass
public static long object_getClass(long obj)
Returns the class of an object.- Parameters:
obj- an Objective-C object- Returns:
- the class object of which object is an instance, or Nil if
objisObjCRuntime.nil
-
object_setClass
public static long object_setClass(long obj, long cls)Sets the class of an object.- Parameters:
obj- the object to modifycls- a class object- Returns:
- the previous value of object's class, or Nil if
objisObjCRuntime.nil
-
object_getClassName
public static java.lang.String object_getClassName(long obj)
Returns the class name of a given object.- Parameters:
obj- an Objective-C object- Returns:
- the name of the class of which
objis an instance
-
object_getIndexedIvars
public static long object_getIndexedIvars(long obj)
This function returns a pointer to any extra bytes allocated with the instance (as specified byObjCRuntime.class_createInstance(long, long)with extraBytes>0). This memory follows the object's ordinary ivars, but may not be adjacent to the last ivar.The returned pointer is guaranteed to be pointer-size aligned, even if the area following the object's last ivar is less aligned than that. Alignment greater than pointer-size is never guaranteed, even if the area following the object's last ivar is more aligned than that.
In a garbage-collected environment, the memory is scanned conservatively.
- Parameters:
obj- an Objective-C object- Returns:
- a pointer to any extra bytes allocated with
obj. Ifobjwas not allocated with any extra bytes, then dereferencing the returned pointer is undefined.
-
object_getIvar
public static long object_getIvar(long obj, long ivar)Reads the value of an instance variable in an object.- Parameters:
obj- the object containing the instance variable whose value you want to readivar- the Ivar describing the instance variable whose value you want to read- Returns:
- the value of the instance variable specified by
ivar, orObjCRuntime.nilifobjisObjCRuntime.nil
-
object_setIvar
public static void object_setIvar(long obj, long ivar, long value)Sets the value of an instance variable in an object.object_setIvar is faster than
ObjCRuntime.object_setInstanceVariable(long, java.nio.ByteBuffer, java.nio.ByteBuffer)if the Ivar for the instance variable is already known.- Parameters:
obj- the object containing the instance variable whose value you want to setivar- the Ivar describing the instance variable whose value you want to setvalue- the new value for the instance variable
-
object_setInstanceVariable
public static long object_setInstanceVariable(long obj, java.nio.ByteBuffer name, java.nio.ByteBuffer value)Changes the value of an instance variable of a class instance.- Parameters:
obj- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to modifyname- a C string. Pass the name of the instance variable whose value you wish to modifyvalue- the new value for the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
object_setInstanceVariable
public static long object_setInstanceVariable(long obj, java.lang.CharSequence name, java.nio.ByteBuffer value)Changes the value of an instance variable of a class instance.- Parameters:
obj- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to modifyname- a C string. Pass the name of the instance variable whose value you wish to modifyvalue- the new value for the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
object_getInstanceVariable
public static long object_getInstanceVariable(long obj, java.nio.ByteBuffer name, PointerBuffer outValue)Obtains the value of an instance variable of a class instance.- Parameters:
obj- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to obtainname- a C string. Pass the name of the instance variable whose value you wish to obtainoutValue- on return, contains a pointer to the value of the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
object_getInstanceVariable
public static long object_getInstanceVariable(long obj, java.lang.CharSequence name, PointerBuffer outValue)Obtains the value of an instance variable of a class instance.- Parameters:
obj- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to obtainname- a C string. Pass the name of the instance variable whose value you wish to obtainoutValue- on return, contains a pointer to the value of the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
objc_getClass
public static long objc_getClass(java.nio.ByteBuffer name)
Returns the class definition of a specified class.objc_getClass is different from
ObjCRuntime.objc_lookUpClass(java.nio.ByteBuffer)in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass does not call the class handler callback.- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_getClass
public static long objc_getClass(java.lang.CharSequence name)
Returns the class definition of a specified class.objc_getClass is different from
ObjCRuntime.objc_lookUpClass(java.nio.ByteBuffer)in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass does not call the class handler callback.- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_getMetaClass
public static long objc_getMetaClass(java.nio.ByteBuffer name)
Returns the metaclass definition of a specified class.If the definition for the named class is not registered, this function calls the class handler callback and then checks a second time to see if the class is registered. However, every class definition must have a valid metaclass definition, and so the metaclass definition is always returned, whether it’s valid or not.
- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the metaclass of the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_getMetaClass
public static long objc_getMetaClass(java.lang.CharSequence name)
Returns the metaclass definition of a specified class.If the definition for the named class is not registered, this function calls the class handler callback and then checks a second time to see if the class is registered. However, every class definition must have a valid metaclass definition, and so the metaclass definition is always returned, whether it’s valid or not.
- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the metaclass of the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_lookUpClass
public static long objc_lookUpClass(java.nio.ByteBuffer name)
Returns the class definition of a specified class.ObjCRuntime.objc_getClass(java.nio.ByteBuffer)is different from this function in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. This function does not call the class handler callback.- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_lookUpClass
public static long objc_lookUpClass(java.lang.CharSequence name)
Returns the class definition of a specified class.ObjCRuntime.objc_getClass(java.nio.ByteBuffer)is different from this function in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. This function does not call the class handler callback.- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class, or
ObjCRuntime.nilif the class is not registered with the Objective-C runtime
-
objc_getRequiredClass
public static long objc_getRequiredClass(java.nio.ByteBuffer name)
Returns the class definition of a specified class.This function is the same as
ObjCRuntime.objc_getClass(java.nio.ByteBuffer), but kills the process if the class is not found.This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class
-
objc_getRequiredClass
public static long objc_getRequiredClass(java.lang.CharSequence name)
Returns the class definition of a specified class.This function is the same as
ObjCRuntime.objc_getClass(java.nio.ByteBuffer), but kills the process if the class is not found.This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
- Parameters:
name- the name of the class to look up- Returns:
- the Class object for the named class
-
objc_getClassList
public static int objc_getClassList(PointerBuffer buffer)
Obtains the list of registered class definitions.The Objective-C runtime library automatically registers all the classes defined in your source code. You can create class definitions at runtime and register them with the
ObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long)andObjCRuntime.objc_registerClassPair(long)functions.Special Considerations
You cannot assume that class objects you get from this function are classes that inherit from NSObject, so you cannot safely call any methods on such classes without detecting that the method is implemented first.
- Parameters:
buffer- an array of Class values. On output, each Class value points to one class definition, up to eitherbufferCountor the total number of registered classes, whichever is less. You can passNULLto obtain the total number of registered class definitions without actually retrieving any class definitions.- Returns:
- an integer value indicating the total number of registered classes
-
objc_copyClassList
public static PointerBuffer objc_copyClassList()
Creates and returns a list of pointers to all registered class definitions.- Returns:
- a
ObjCRuntime.nilterminated array of classes. You must free the array with free()
-
class_getName
public static java.lang.String class_getName(long cls)
Returns the name of a class.- Parameters:
cls- a class object- Returns:
- the name of the class, or the empty string if cls is Nil
-
class_isMetaClass
public static boolean class_isMetaClass(long cls)
Returns a Boolean value that indicates whether a class object is a metaclass.- Parameters:
cls- a class object- Returns:
ObjCRuntime.YESif cls is a metaclass,ObjCRuntime.NOif cls is a non-meta class,ObjCRuntime.NOif cls is Nil
-
class_getSuperclass
public static long class_getSuperclass(long cls)
Returns the superclass of a class.- Parameters:
cls- a class object- Returns:
- the superclass of the class, or Nil if cls is a root class, or Nil if cls is Nil
-
class_getVersion
public static int class_getVersion(long cls)
Returns the version number of a class definition.You can use the version number of the class definition to provide versioning of the interface that your class represents to other classes. This is especially useful for object serialization (that is, archiving of the object in a flattened form), where it is important to recognize changes to the layout of the instance variables in different class-definition versions.
Classes derived from the Foundation framework NSObject class can obtain the class-definition version number using the getVersion class method, which is implemented using the class_getVersion function.
- Parameters:
cls- a pointer to an Class data structure. Pass the class definition for which you wish to obtain the version- Returns:
- an integer indicating the version number of the class definition
-
class_setVersion
public static void class_setVersion(long cls, int version)Sets the version number of a class definition.You can use the version number of the class definition to provide versioning of the interface that your class represents to other classes. This is especially useful for object serialization (that is, archiving of the object in a flattened form), where it is important to recognize changes to the layout of the instance variables in different class-definition versions.
Classes derived from the Foundation framework NSObject class can set the class-definition version number using the setVersion: class method, which is implemented using the class_setVersion function.
- Parameters:
cls- a pointer to an Class data structure. Pass the class definition for which you wish to set the versionversion- the new version number of the class definition
-
class_getInstanceSize
public static long class_getInstanceSize(long cls)
Returns the size of instances of a class.- Parameters:
cls- a class object- Returns:
- the size in bytes of instances of the class
cls, or 0 ifclsis Nil
-
class_getInstanceVariable
public static long class_getInstanceVariable(long cls, java.nio.ByteBuffer name)Returns the Ivar for a specified instance variable of a given class.- Parameters:
cls- the class whose instance variable you wish to obtainname- the name of the instance variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the instance variable specified by name
-
class_getInstanceVariable
public static long class_getInstanceVariable(long cls, java.lang.CharSequence name)Returns the Ivar for a specified instance variable of a given class.- Parameters:
cls- the class whose instance variable you wish to obtainname- the name of the instance variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the instance variable specified by name
-
class_getClassVariable
public static long class_getClassVariable(long cls, java.nio.ByteBuffer name)Returns the Ivar for a specified class variable of a given class.- Parameters:
cls- the class definition whose class variable you wish to obtainname- the name of the class variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the class variable specified by name
-
class_getClassVariable
public static long class_getClassVariable(long cls, java.lang.CharSequence name)Returns the Ivar for a specified class variable of a given class.- Parameters:
cls- the class definition whose class variable you wish to obtainname- the name of the class variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the class variable specified by name
-
class_copyIvarList
public static PointerBuffer class_copyIvarList(long cls)
Describes the instance variables declared by a class.- Parameters:
cls- the class to inspect- Returns:
- an array of pointers of type Ivar describing the instance variables declared by the class. Any instance variables declared by superclasses are not
included. The array contains
*outCountpointers followed by aNULLterminator. You must free the array with free().If the class declares no instance variables, or
clsis Nil,NULLis returned and*outCountis 0.
-
class_getInstanceMethod
public static long class_getInstanceMethod(long cls, long name)Returns a specified instance method for a given class.Note that this function searches superclasses for implementations, whereas
ObjCRuntime.class_copyMethodList(long)does not.- Parameters:
cls- the class you want to inspectname- the selector of the method you want to retrieve- Returns:
- the method that corresponds to the implementation of the selector specified by aSelector for the class specified by
cls, orNULLif the specified class or its superclasses do not contain an instance method with the specified selector.
-
class_getClassMethod
public static long class_getClassMethod(long cls, long name)Returns a pointer to the data structure describing a given class method for a given class.Note that this function searches superclasses for implementations, whereas
ObjCRuntime.class_copyMethodList(long)does not.- Parameters:
cls- a pointer to a class definition. Pass the class that contains the method you want to retrievename- a pointer of type SEL. Pass the selector of the method you want to retrieve- Returns:
- a pointer to the Method data structure that corresponds to the implementation of the selector specified by
namefor the class specified bycls, orNULLif the specified class or its superclasses do not contain a class method with the specified selector.
-
class_getMethodImplementation
public static long class_getMethodImplementation(long cls, long name)Returns the function pointer that would be called if a particular message were sent to an instance of a class.class_getMethodImplementation may be faster than
method_getImplementation(class_getInstanceMethod(cls, name)).The function pointer returned may be a function internal to the runtime instead of an actual method implementation. For example, if instances of the class do not respond to the selector, the function pointer returned will be part of the runtime's message forwarding machinery.
- Parameters:
cls- the class you want to inspectname- a selector- Returns:
- the function pointer that would be called if
[object name]were called with an instance of the class, orNULLifclsis Nil
-
class_respondsToSelector
public static boolean class_respondsToSelector(long cls, long name)Returns a Boolean value that indicates whether instances of a class respond to a particular selector.You should usually use NSObject's respondsToSelector: or instancesRespondToSelector: methods instead of this function.
- Parameters:
cls- the class you want to inspectname- a selector- Returns:
ObjCRuntime.YESif instances of the class respond to the selector, otherwiseObjCRuntime.NO
-
class_copyMethodList
public static PointerBuffer class_copyMethodList(long cls)
Describes the instance methods implemented by a class.- Parameters:
cls- the class you want to inspect- Returns:
- an array of pointers of type Method describing the instance methods implemented by the class—any instance methods implemented by superclasses are not
included. The array contains
*outCountpointers followed by aNULLterminator. You must free the array with free().If
clsimplements no instance methods, orclsis Nil, returnsNULLand*outCountis 0.
-
class_conformsToProtocol
public static boolean class_conformsToProtocol(long cls, long protocol)Returns a Boolean value that indicates whether a class conforms to a given protocol.You should usually use NSObject's conformsToProtocol: method instead of this function.
- Parameters:
cls- the class you want to inspectprotocol- a protocol- Returns:
ObjCRuntime.YESifclsconforms toprotocol, otherwiseObjCRuntime.NO
-
class_copyProtocolList
public static PointerBuffer class_copyProtocolList(long cls)
Describes the protocols adopted by a class.- Parameters:
cls- the class you want to inspect- Returns:
- an array of pointers of type Protocol* describing the protocols adopted by the class. Any protocols adopted by superclasses or other protocols are not
included. The array contains
*outCountpointers followed by aNULLterminator. You must free the array with free().If
clsadopts no protocols, orclsis Nil, returnsNULLand*outCountis 0.
-
class_getProperty
public static long class_getProperty(long cls, java.nio.ByteBuffer name)Returns a property with a given name of a given class.- Parameters:
cls- the class you want to inspectname- a C string. Pass the name of the instance variable whose value you wish to modify.- Returns:
- a pointer of type
objc_property_tdescribing the property, orNULLif the class does not declare a property with that name, orNULLifclsis Nil.
-
class_getProperty
public static long class_getProperty(long cls, java.lang.CharSequence name)Returns a property with a given name of a given class.- Parameters:
cls- the class you want to inspectname- a C string. Pass the name of the instance variable whose value you wish to modify.- Returns:
- a pointer of type
objc_property_tdescribing the property, orNULLif the class does not declare a property with that name, orNULLifclsis Nil.
-
class_copyPropertyList
public static PointerBuffer class_copyPropertyList(long cls)
Describes the properties declared by a class.- Parameters:
cls- the class you want to inspect- Returns:
- an array of pointers of type
objc_property_tdescribing the properties declared by the class. Any properties declared by superclasses are not included. The array contains*outCountpointers followed by aNULLterminator. You must free the array with free().If
clsdeclares no properties, orclsis Nil, returnsNULLand*outCountis 0.
-
class_getIvarLayout
public static java.lang.String class_getIvarLayout(long cls)
Returns a description of the Ivar layout for a given class.- Parameters:
cls- the class to inspect- Returns:
- a description of the Ivar layout for
cls
-
class_getWeakIvarLayout
public static java.lang.String class_getWeakIvarLayout(long cls)
Returns a description of the layout of weak Ivars for a given class.- Parameters:
cls- the class to inspect- Returns:
- a description of the layout of the weak Ivars for
cls
-
class_addMethod
public static boolean class_addMethod(long cls, long name, long imp, java.nio.ByteBuffer types)Adds a new method to a class with a given name and implementation.Discussion
class_addMethod will add an override of a superclass's implementation, but will not replace an existing implementation in this class. To change an existing implementation, use
ObjCRuntime.method_setImplementation(long, long).An Objective-C method is simply a C function that takes at least two arguments –
selfand_cmd. For example, given the following function:void myMethodIMP(id self, SEL _cmd) { // implementation .... }you can dynamically add it to a class as a method (called
resolveThisMethodDynamically) like this:class_addMethod([self class], @selector(resolveThisMethodDynamically), (IMP) myMethodIMP, "v@:");- Parameters:
cls- the class to which to add a methodname- a selector that specifies the name of the method being addedimp- a function which is the implementation of the new method. The function must take at least two arguments –selfand_cmd.types- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –selfand_cmd, the second and third characters must be “@:” (the first character is the return type).- Returns:
ObjCRuntime.YESif the method was added successfully, otherwiseObjCRuntime.NO(for example, the class already contains a method implementation with that name)
-
class_addMethod
public static boolean class_addMethod(long cls, long name, long imp, java.lang.CharSequence types)Adds a new method to a class with a given name and implementation.Discussion
class_addMethod will add an override of a superclass's implementation, but will not replace an existing implementation in this class. To change an existing implementation, use
ObjCRuntime.method_setImplementation(long, long).An Objective-C method is simply a C function that takes at least two arguments –
selfand_cmd. For example, given the following function:void myMethodIMP(id self, SEL _cmd) { // implementation .... }you can dynamically add it to a class as a method (called
resolveThisMethodDynamically) like this:class_addMethod([self class], @selector(resolveThisMethodDynamically), (IMP) myMethodIMP, "v@:");- Parameters:
cls- the class to which to add a methodname- a selector that specifies the name of the method being addedimp- a function which is the implementation of the new method. The function must take at least two arguments –selfand_cmd.types- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –selfand_cmd, the second and third characters must be “@:” (the first character is the return type).- Returns:
ObjCRuntime.YESif the method was added successfully, otherwiseObjCRuntime.NO(for example, the class already contains a method implementation with that name)
-
class_replaceMethod
public static long class_replaceMethod(long cls, long name, long imp, java.nio.ByteBuffer types)Replaces the implementation of a method for a given class.Discussion
This function behaves in two different ways:
- If the method identified by name does not yet exist, it is added as if class_addMethod were called. The type encoding specified by types is used as given.
- If the method identified by name does exist, its IMP is replaced as if method_setImplementation were called. The type encoding specified by types is ignored.
- Parameters:
cls- the class you want to modifyname- a selector that identifies the method whose implementation you want to replaceimp- the new implementation for the method identified bynamefor the class identified byclstypes- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –selfand_cmd, the second and third characters must be “@:” (the first character is the return type).- Returns:
- the previous implementation of the method identified by
namefor the class identified bycls
-
class_replaceMethod
public static long class_replaceMethod(long cls, long name, long imp, java.lang.CharSequence types)Replaces the implementation of a method for a given class.Discussion
This function behaves in two different ways:
- If the method identified by name does not yet exist, it is added as if class_addMethod were called. The type encoding specified by types is used as given.
- If the method identified by name does exist, its IMP is replaced as if method_setImplementation were called. The type encoding specified by types is ignored.
- Parameters:
cls- the class you want to modifyname- a selector that identifies the method whose implementation you want to replaceimp- the new implementation for the method identified bynamefor the class identified byclstypes- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –selfand_cmd, the second and third characters must be “@:” (the first character is the return type).- Returns:
- the previous implementation of the method identified by
namefor the class identified bycls
-
class_addIvar
public static boolean class_addIvar(long cls, java.nio.ByteBuffer name, long size, byte alignment, java.nio.ByteBuffer types)Adds a new instance variable to a class.This function may only be called after
ObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long)and beforeObjCRuntime.objc_registerClassPair(long). Adding an instance variable to an existing class is not supported.The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
The instance variable's minimum alignment in bytes is
1<. The minimum alignment of an instance variable depends on the ivar's type and the machine architecture. For variables of any pointer type, pass log2(sizeof(pointer_type)).- Parameters:
cls-name-size-alignment-types-- Returns:
ObjCRuntime.YESif the instance variable was added successfully, otherwiseObjCRuntime.NO(for example, the class already contains an instance variable with that name)
-
class_addIvar
public static boolean class_addIvar(long cls, java.lang.CharSequence name, long size, byte alignment, java.lang.CharSequence types)Adds a new instance variable to a class.This function may only be called after
ObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long)and beforeObjCRuntime.objc_registerClassPair(long). Adding an instance variable to an existing class is not supported.The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
The instance variable's minimum alignment in bytes is
1<. The minimum alignment of an instance variable depends on the ivar's type and the machine architecture. For variables of any pointer type, pass log2(sizeof(pointer_type)).- Parameters:
cls-name-size-alignment-types-- Returns:
ObjCRuntime.YESif the instance variable was added successfully, otherwiseObjCRuntime.NO(for example, the class already contains an instance variable with that name)
-
class_addProtocol
public static boolean class_addProtocol(long cls, long protocol)Adds a protocol to a class.- Parameters:
cls- the class to modifyprotocol- the protocol to add tocls- Returns:
ObjCRuntime.YESif the protocol was added successfully, otherwiseObjCRuntime.NO(for example, the class already conforms to that protocol)
-
class_addProperty
public static boolean class_addProperty(long cls, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes)Adds a property to a class.- Parameters:
cls- the class to modifyname- the name of the propertyattributes- an array of property attributes- Returns:
ObjCRuntime.YESif the property was added successfully; otherwiseObjCRuntime.NO(for example, this function returnsObjCRuntime.NOif the class already has that property)
-
class_addProperty
public static boolean class_addProperty(long cls, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes)Adds a property to a class.- Parameters:
cls- the class to modifyname- the name of the propertyattributes- an array of property attributes- Returns:
ObjCRuntime.YESif the property was added successfully; otherwiseObjCRuntime.NO(for example, this function returnsObjCRuntime.NOif the class already has that property)
-
class_replaceProperty
public static void class_replaceProperty(long cls, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes)Replaces a property of a class.- Parameters:
cls- the class to modifyname- the name of the propertyattributes- an array of property attributes
-
class_replaceProperty
public static void class_replaceProperty(long cls, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes)Replaces a property of a class.- Parameters:
cls- the class to modifyname- the name of the propertyattributes- an array of property attributes
-
class_setIvarLayout
public static void class_setIvarLayout(long cls, java.nio.ByteBuffer layout)Sets the Ivar layout for a given class.- Parameters:
cls- the class to modifylayout- the layout of the Ivars forcls
-
class_setIvarLayout
public static void class_setIvarLayout(long cls, java.lang.CharSequence layout)Sets the Ivar layout for a given class.- Parameters:
cls- the class to modifylayout- the layout of the Ivars forcls
-
class_setWeakIvarLayout
public static void class_setWeakIvarLayout(long cls, java.nio.ByteBuffer layout)Sets the layout for weak Ivars for a given class.- Parameters:
cls- the class to modifylayout- the layout of the weak Ivars forcls
-
class_setWeakIvarLayout
public static void class_setWeakIvarLayout(long cls, java.lang.CharSequence layout)Sets the layout for weak Ivars for a given class.- Parameters:
cls- the class to modifylayout- the layout of the weak Ivars forcls
-
class_createInstance
public static long class_createInstance(long cls, long extraBytes)Creates an instance of a class, allocating memory for the class in the default malloc memory zone.- Parameters:
cls- the class that you want to allocate an instance ofextraBytes- an integer indicating the number of extra bytes to allocate. The additional bytes can be used to store additional instance variables beyond those defined in the class definition.- Returns:
- an instance of the class
cls
-
objc_constructInstance
public static long objc_constructInstance(long cls, java.nio.ByteBuffer bytes)Creates an instance of a class at the specified location.- Parameters:
cls- the class that you want to allocate an instance ofbytes- the location at which to allocate an instance of theclsclass.bytesmust point to at leastclass_getInstanceSize(cls)bytes of well-aligned, zero-filled memory.- Returns:
- an instance of the class
clsatbytes, if successful; otherwiseObjCRuntime.nil(for example, ifclsorbytesare themselvesObjCRuntime.nil)
-
objc_destructInstance
public static long objc_destructInstance(long obj)
Destroys an instance of a class without freeing memory and removes any of its associated references.This method does nothing if obj is
ObjCRuntime.nil.Important
The garbage collector does not call this function. As a result, if you edit this function, you should also edit finalize. That said, Core Foundation and other clients do call this function under garbage collection.
- Parameters:
obj- the instance to destroy
-
objc_allocateClassPair
public static long objc_allocateClassPair(long superclass, java.nio.ByteBuffer name, long extraBytes)Creates a new class and metaclass.You can get a pointer to the new metaclass by calling
object_getClass(newClass).To create a new class, start by calling objc_allocateClassPair. Then set the class's attributes with functions like
ObjCRuntime.class_addMethod(long, long, long, java.nio.ByteBuffer)andObjCRuntime.class_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer). When you are done building the class, callObjCRuntime.objc_registerClassPair(long). The new class is now ready for use.Instance methods and instance variables should be added to the class itself. Class methods should be added to the metaclass.
- Parameters:
superclass- the class to use as the new class's superclass, or Nil to create a new root classname- the string to use as the new class's name. The string will be copied.extraBytes- the number of bytes to allocate for indexed ivars at the end of the class and metaclass objects. This should usually be 0.- Returns:
- the new class, or Nil if the class could not be created (for example, the desired name is already in use)
-
objc_allocateClassPair
public static long objc_allocateClassPair(long superclass, java.lang.CharSequence name, long extraBytes)Creates a new class and metaclass.You can get a pointer to the new metaclass by calling
object_getClass(newClass).To create a new class, start by calling objc_allocateClassPair. Then set the class's attributes with functions like
ObjCRuntime.class_addMethod(long, long, long, java.nio.ByteBuffer)andObjCRuntime.class_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer). When you are done building the class, callObjCRuntime.objc_registerClassPair(long). The new class is now ready for use.Instance methods and instance variables should be added to the class itself. Class methods should be added to the metaclass.
- Parameters:
superclass- the class to use as the new class's superclass, or Nil to create a new root classname- the string to use as the new class's name. The string will be copied.extraBytes- the number of bytes to allocate for indexed ivars at the end of the class and metaclass objects. This should usually be 0.- Returns:
- the new class, or Nil if the class could not be created (for example, the desired name is already in use)
-
objc_registerClassPair
public static void objc_registerClassPair(long cls)
Registers a class that was allocated usingObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long).- Parameters:
cls- the class you want to register
-
objc_disposeClassPair
public static void objc_disposeClassPair(long cls)
Destroys a class and its associated metaclass.Do not call this function if instances of the
clsclass or any subclass exist.- Parameters:
cls- the class to be destroyed. This class must have been allocated usingObjCRuntime.objc_allocateClassPair(long, java.nio.ByteBuffer, long).
-
method_getName
public static long method_getName(long m)
Returns the name of a method.To get the method name as a C string, call
sel_getName(method_getName(method)).- Parameters:
m- the method to inspect- Returns:
- a pointer of type SEL
-
method_getImplementation
public static long method_getImplementation(long m)
Returns the implementation of a method.- Parameters:
m- the method to inspect- Returns:
- a function pointer of type IMP
-
method_getTypeEncoding
public static java.lang.String method_getTypeEncoding(long m)
Returns a string describing a method's parameter and return types.- Parameters:
m- the method to inspect- Returns:
- a C string. The string may be
NULL
-
method_getNumberOfArguments
public static int method_getNumberOfArguments(long m)
Returns the number of arguments accepted by a method.- Parameters:
m- a pointer to a Method data structure. Pass the method in question.- Returns:
- an integer containing the number of arguments accepted by the given method
-
method_copyReturnType
public static java.lang.String method_copyReturnType(long m)
Returns a string describing a method's return type.- Parameters:
m- the method to inspect- Returns:
- a C string describing the return type. You must free the string with free().
-
method_copyArgumentType
public static java.lang.String method_copyArgumentType(long m, int index)Returns a string describing a single parameter type of a method.- Parameters:
m- the method to inspectindex- the index of the parameter to inspect- Returns:
- a C string describing the type of the parameter at index
index, orNULLif method has no parameter indexindex. You must free the string with free().
-
method_getReturnType
public static void method_getReturnType(long m, java.nio.ByteBuffer dst)Returns by reference a string describing a method's return type.The method's return type string is copied to
dst.dstis filled as ifstrncpy(dst, parameter_type, dst_len)were called.- Parameters:
m- the method to inspectdst- the reference string to store the description
-
method_getReturnType
public static java.lang.String method_getReturnType(long m, long dst_len)Returns by reference a string describing a method's return type.The method's return type string is copied to
dst.dstis filled as ifstrncpy(dst, parameter_type, dst_len)were called.- Parameters:
m- the method to inspectdst_len- the maximum number of characters that can be stored indst
-
method_getArgumentType
public static void method_getArgumentType(long m, int index, java.nio.ByteBuffer dst)Returns by reference a string describing a single parameter type of a method.The parameter type string is copied to
dst.dstis filled as ifstrncpy(dst, parameter_type, dst_len)were called. If the method contains no parameter with that index,dstis filled as ifstrncpy(dst, "", dst_len)were called.- Parameters:
m- the method you want to inquire aboutindex- the index of the parameter you want to inquire aboutdst- the reference string to store the description
-
method_getArgumentType
public static java.lang.String method_getArgumentType(long m, int index, long dst_len)Returns by reference a string describing a single parameter type of a method.The parameter type string is copied to
dst.dstis filled as ifstrncpy(dst, parameter_type, dst_len)were called. If the method contains no parameter with that index,dstis filled as ifstrncpy(dst, "", dst_len)were called.- Parameters:
m- the method you want to inquire aboutindex- the index of the parameter you want to inquire aboutdst_len- the maximum number of characters that can be stored indst
-
method_setImplementation
public static long method_setImplementation(long m, long imp)Sets the implementation of a method.- Parameters:
m- the method for which to set an implementationimp- the implemention to set to this method- Returns:
- the previous implementation of the method
-
method_exchangeImplementations
public static void method_exchangeImplementations(long m1, long m2)Exchanges the implementations of two methods.- Parameters:
m1- the method to exchange with second methodm2- the method to exchange with first method
-
ivar_getName
public static java.lang.String ivar_getName(long v)
Returns the name of an instance variable.- Parameters:
v- the instance variable- Returns:
- a C string containing the instance variable's name
-
ivar_getTypeEncoding
public static java.lang.String ivar_getTypeEncoding(long v)
Returns the type string of an instance variable.- Parameters:
v- the instance variable- Returns:
- a C string containing the instance variable's type encoding
-
ivar_getOffset
public static long ivar_getOffset(long v)
Returns the offset of an instance variable.For instance variables of type
idor other object types, callObjCRuntime.object_getIvar(long, long)andObjCRuntime.object_setIvar(long, long, long)instead of using this offset to access the instance variable data directly.- Parameters:
v- the instance variable- Returns:
- the offset of
v
-
property_getName
public static java.lang.String property_getName(long property)
Returns the name of a property.- Parameters:
property- the property you want to inquire about- Returns:
- a C string containing the property's name
-
property_getAttributes
public static java.lang.String property_getAttributes(long property)
Returns the attribute string of a property.- Parameters:
property- a property- Returns:
- a C string containing the property's attributes
-
property_copyAttributeList
public static ObjCPropertyAttribute.Buffer property_copyAttributeList(long property)
Returns an array of property attributes for a given property.- Parameters:
property- the property whose attributes you want to copy- Returns:
- an array of property attributes. You must free the array with free().
-
property_copyAttributeValue
public static java.lang.String property_copyAttributeValue(long property, java.nio.ByteBuffer attributeName)Returns the value of a property attribute given the attribute name.- Parameters:
property- the property whose value you are interested inattributeName- a C string representing the name of the attribute- Returns:
- The value string of the
attributeNameattribute, if one exists inproperty; otherwise,ObjCRuntime.nil. You must free the returned value string with free().
-
property_copyAttributeValue
public static java.lang.String property_copyAttributeValue(long property, java.lang.CharSequence attributeName)Returns the value of a property attribute given the attribute name.- Parameters:
property- the property whose value you are interested inattributeName- a C string representing the name of the attribute- Returns:
- The value string of the
attributeNameattribute, if one exists inproperty; otherwise,ObjCRuntime.nil. You must free the returned value string with free().
-
objc_getProtocol
public static long objc_getProtocol(java.nio.ByteBuffer name)
Returns a specified protocol.This function acquires the runtime lock.
- Parameters:
name- the name of a protocol- Returns:
- the protocol named
name{, orNULLif no protocol named name could be found
-
objc_getProtocol
public static long objc_getProtocol(java.lang.CharSequence name)
Returns a specified protocol.This function acquires the runtime lock.
- Parameters:
name- the name of a protocol- Returns:
- the protocol named
name{, orNULLif no protocol named name could be found
-
objc_copyProtocolList
public static PointerBuffer objc_copyProtocolList()
Returns an array of all the protocols known to the runtime.- Returns:
- a C array of all the protocols known to the runtime. The array contains
*outCountpointers followed by aNULLterminator. You must free the list with free().
-
protocol_conformsToProtocol
public static boolean protocol_conformsToProtocol(long proto, long other)Returns a Boolean value that indicates whether one protocol conforms to another protocol.Discussion
One protocol can incorporate other protocols using the same syntax that classes use to adopt a protocol:
@protocol ProtocolName < protocol list >All the protocols listed between angle brackets are considered part of the
ProtocolNameprotocol.- Parameters:
proto- a protocolother- a protocol- Returns:
ObjCRuntime.YESifprotoconforms toother, otherwiseObjCRuntime.NO
-
protocol_isEqual
public static boolean protocol_isEqual(long proto, long other)Returns a Boolean value that indicates whether two protocols are equal.- Parameters:
proto- a protocolother- a protocol- Returns:
ObjCRuntime.YESif proto is the same as other, otherwiseObjCRuntime.NO
-
protocol_getName
public static java.lang.String protocol_getName(long p)
Returns a the name of a protocol.- Parameters:
p- a protocol- Returns:
- the name of the protocol
pas a C string
-
protocol_getMethodDescription
public static ObjCMethodDescription protocol_getMethodDescription(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, ObjCMethodDescription __result)
Returns a method description structure for a specified method of a given protocol.- Parameters:
p- a protocolaSel- a selectorisRequiredMethod- a Boolean value that indicates whetheraSelis a required methodisInstanceMethod- a Boolean value that indicates whetheraSelis a instance method__result- an objc_method_description structure that describes the method specified byaSel,isRequiredMethod, andisInstanceMethodfor the protocolp.If the protocol does not contain the specified method, returns an objc_method_description structure with the value
{NULL, NULL}.
-
protocol_copyMethodDescriptionList
public static ObjCMethodDescription.Buffer protocol_copyMethodDescriptionList(long p, boolean isRequiredMethod, boolean isInstanceMethod)
Returns an array of method descriptions of methods meeting a given specification for a given protocol.Methods in other protocols adopted by this protocol are not included.
- Parameters:
p- a protocolisRequiredMethod- a Boolean value that indicates whether returned methods should be required methods (passObjCRuntime.YESto specify required methods)isInstanceMethod- a Boolean value that indicates whether returned methods should be instance methods (passObjCRuntime.YESto specify instance methods)- Returns:
- a C array of objc_method_description structures containing the names and types of
p's methods specified byisRequiredMethodandisInstanceMethod. The array contains*outCountpointers followed by aNULLterminator. You must free the list with free().If the protocol declares no methods that meet the specification,
NULLis returned and*outCountis 0.
-
protocol_getProperty
public static long protocol_getProperty(long proto, java.nio.ByteBuffer name, boolean isRequiredProperty, boolean isInstanceProperty)Returns the specified property of a given protocol.- Parameters:
proto- a protocolname- the name of a propertyisRequiredProperty- a Boolean value that indicates whethernameis a required propertyisInstanceProperty- a Boolean value that indicates whethernameis a instance property- Returns:
- the property specified by
name,isRequiredProperty, andisInstancePropertyforproto, orNULLif none ofproto's properties meets the specification
-
protocol_getProperty
public static long protocol_getProperty(long proto, java.lang.CharSequence name, boolean isRequiredProperty, boolean isInstanceProperty)Returns the specified property of a given protocol.- Parameters:
proto- a protocolname- the name of a propertyisRequiredProperty- a Boolean value that indicates whethernameis a required propertyisInstanceProperty- a Boolean value that indicates whethernameis a instance property- Returns:
- the property specified by
name,isRequiredProperty, andisInstancePropertyforproto, orNULLif none ofproto's properties meets the specification
-
protocol_copyPropertyList
public static PointerBuffer protocol_copyPropertyList(long proto)
Returns an array of the properties declared by a protocol.- Parameters:
proto- a protocol- Returns:
- a C array of pointers of type objc_property_t describing the properties declared by
proto. Any properties declared by other protocols adopted by this protocol are not included. The array contains*outCountpointers followed by aNULLterminator. You must free the array with free().If the protocol declares no properties,
NULLis returned and*outCountis 0.
-
protocol_copyProtocolList
public static PointerBuffer protocol_copyProtocolList(long proto)
eturns an array of the protocols adopted by a protocol.- Parameters:
proto- a protocol- Returns:
- a C array of protocols adopted by
proto. The array contains*outCountpointers followed by aNULLterminator. You must free the array with free().If the protocol declares no properties,
NULLis returned and*outCountis 0.
-
objc_allocateProtocol
public static long objc_allocateProtocol(java.nio.ByteBuffer name)
Creates a new protocol instance.You must register the returned protocol instance with the
ObjCRuntime.objc_registerProtocol(long)function before you can use it.There is no dispose method associated with this function.
- Parameters:
name- the name of the protocol you want to create- Returns:
- a new protocol instance or
ObjCRuntime.nilif a protocol with the same name asnamealready exists
-
objc_allocateProtocol
public static long objc_allocateProtocol(java.lang.CharSequence name)
Creates a new protocol instance.You must register the returned protocol instance with the
ObjCRuntime.objc_registerProtocol(long)function before you can use it.There is no dispose method associated with this function.
- Parameters:
name- the name of the protocol you want to create- Returns:
- a new protocol instance or
ObjCRuntime.nilif a protocol with the same name asnamealready exists
-
objc_registerProtocol
public static void objc_registerProtocol(long proto)
Registers a newly created protocol with the Objective-C runtime.When you create a new protocol using the
ObjCRuntime.objc_allocateProtocol(java.nio.ByteBuffer), you then register it with the Objective-C runtime by calling this function. After a protocol is successfully registered, it is immutable and ready to use.- Parameters:
proto- the protocol you want to register with the Objective-C runtime
-
protocol_addMethodDescription
public static void protocol_addMethodDescription(long proto, long name, java.nio.ByteBuffer types, boolean isRequiredMethod, boolean isInstanceMethod)Adds a method to a protocol.To add a method to a protocol using this function, the protocol must be under construction. That is, you must add any methods to proto before you register it with the Objective-C runtime (via the
ObjCRuntime.objc_registerProtocol(long)function).- Parameters:
proto- the protocol you want to add a method toname- the name of the method you want to addtypes- a C string representing the signature of the method you want to addisRequiredMethod- a Boolean indicating whether the method is a required method of theprotoprotocol. IfObjCRuntime.YES, the method is a required method; ifObjCRuntime.NO, the method is an optional method.isInstanceMethod- a Boolean indicating whether the method is an instance method. IfObjCRuntime.YES, the method is an instance method; ifObjCRuntime.NO, the method is a class method.
-
protocol_addMethodDescription
public static void protocol_addMethodDescription(long proto, long name, java.lang.CharSequence types, boolean isRequiredMethod, boolean isInstanceMethod)Adds a method to a protocol.To add a method to a protocol using this function, the protocol must be under construction. That is, you must add any methods to proto before you register it with the Objective-C runtime (via the
ObjCRuntime.objc_registerProtocol(long)function).- Parameters:
proto- the protocol you want to add a method toname- the name of the method you want to addtypes- a C string representing the signature of the method you want to addisRequiredMethod- a Boolean indicating whether the method is a required method of theprotoprotocol. IfObjCRuntime.YES, the method is a required method; ifObjCRuntime.NO, the method is an optional method.isInstanceMethod- a Boolean indicating whether the method is an instance method. IfObjCRuntime.YES, the method is an instance method; ifObjCRuntime.NO, the method is a class method.
-
protocol_addProtocol
public static void protocol_addProtocol(long proto, long addition)Adds a registered protocol to another protocol that is under construction.The protocol you want to add to (
proto) must be under construction – allocated but not yet registered with the Objective-C runtime. The protocol you want to add (addition) must be registered already.- Parameters:
proto- the protocol you want to add the registered protocol toaddition- the registered protocol you want to add toproto
-
protocol_addProperty
public static void protocol_addProperty(long proto, java.nio.ByteBuffer name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty)Adds a property to a protocol that is under construction.The protocol you want to add the property to must be under construction – allocated but not yet registered with the Objective-C runtime (via the
ObjCRuntime.objc_registerProtocol(long)function).- Parameters:
proto- the protocol you want to add a property toname- the name of the property you want to add.attributes- an array of property attributesisRequiredProperty- a Boolean indicating whether the property's accessor methods are required methods of theprotoprotocol. IfObjCRuntime.YES, the property's accessor methods are required methods; ifObjCRuntime.NO, the property's accessor methods are optional methods.isInstanceProperty- a Boolean indicating whether the property's accessor methods are instance methods. IfObjCRuntime.YES, the property's accessor methods are instance methods.ObjCRuntime.YESis the only value allowed for a property. As a result, if you set this value toObjCRuntime.NO, the property will not be added to the protocol.
-
protocol_addProperty
public static void protocol_addProperty(long proto, java.lang.CharSequence name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty)Adds a property to a protocol that is under construction.The protocol you want to add the property to must be under construction – allocated but not yet registered with the Objective-C runtime (via the
ObjCRuntime.objc_registerProtocol(long)function).- Parameters:
proto- the protocol you want to add a property toname- the name of the property you want to add.attributes- an array of property attributesisRequiredProperty- a Boolean indicating whether the property's accessor methods are required methods of theprotoprotocol. IfObjCRuntime.YES, the property's accessor methods are required methods; ifObjCRuntime.NO, the property's accessor methods are optional methods.isInstanceProperty- a Boolean indicating whether the property's accessor methods are instance methods. IfObjCRuntime.YES, the property's accessor methods are instance methods.ObjCRuntime.YESis the only value allowed for a property. As a result, if you set this value toObjCRuntime.NO, the property will not be added to the protocol.
-
objc_copyImageNames
public static PointerBuffer objc_copyImageNames()
Returns the names of all the loaded Objective-C frameworks and dynamic libraries.- Returns:
- an array of C strings representing the names of all the loaded Objective-C frameworks and dynamic libraries
-
class_getImageName
public static java.lang.String class_getImageName(long cls)
Returns the name of the dynamic library a class originated from.- Parameters:
cls- the class you are inquiring about- Returns:
- a C string representing the name of the library containing the
clsclass.
-
objc_copyClassNamesForImage
public static PointerBuffer objc_copyClassNamesForImage(java.nio.ByteBuffer image)
Returns the names of all the classes within a specified library or framework.- Parameters:
image- the library or framework you are inquiring about- Returns:
- an array of C strings representing all of the class names within the specified library or framework
-
objc_copyClassNamesForImage
public static PointerBuffer objc_copyClassNamesForImage(java.lang.CharSequence image)
Returns the names of all the classes within a specified library or framework.- Parameters:
image- the library or framework you are inquiring about- Returns:
- an array of C strings representing all of the class names within the specified library or framework
-
sel_getName
public static java.lang.String sel_getName(long sel)
Returns the name of the method specified by a given selector.- Parameters:
sel- a pointer of type SEL. Pass the selector whose name you wish to determine.- Returns:
- a C string indicating the name of the selector
-
sel_getUid
public static long sel_getUid(java.nio.ByteBuffer str)
Registers a method name with the Objective-C runtime system.The implementation of this method is identical to the implementation of
ObjCRuntime.sel_registerName(java.nio.ByteBuffer).- Parameters:
str- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_getUid
public static long sel_getUid(java.lang.CharSequence str)
Registers a method name with the Objective-C runtime system.The implementation of this method is identical to the implementation of
ObjCRuntime.sel_registerName(java.nio.ByteBuffer).- Parameters:
str- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_registerName
public static long sel_registerName(java.nio.ByteBuffer str)
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.You must register a method name with the Objective-C runtime system to obtain the method’s selector before you can add the method to a class definition. If the method name has already been registered, this function simply returns the selector.
- Parameters:
str- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_registerName
public static long sel_registerName(java.lang.CharSequence str)
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.You must register a method name with the Objective-C runtime system to obtain the method’s selector before you can add the method to a class definition. If the method name has already been registered, this function simply returns the selector.
- Parameters:
str- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_isEqual
public static boolean sel_isEqual(long lhs, long rhs)Returns a Boolean value that indicates whether two selectors are equal.sel_isEqual is equivalent to
==.- Parameters:
lhs- the selector to compare withrhsrhs- the selector to compare withlhs- Returns:
ObjCRuntime.YESif rhs and rhs are equal, otherwiseObjCRuntime.NO
-
objc_enumerationMutation
public static void objc_enumerationMutation(long obj)
Inserted by the compiler when a mutation is detected during a foreach iteration.The compiler inserts this function when it detects that an object is mutated during a foreach iteration. The function is called when a mutation occurs, and the enumeration mutation handler is enacted if it is set up (via the
ObjCRuntime.objc_setEnumerationMutationHandler(org.lwjgl.system.macosx.EnumerationMutationHandlerI)function). If the handler is not set up, a fatal error occurs.- Parameters:
obj- the object being mutated
-
objc_setEnumerationMutationHandler
public static void objc_setEnumerationMutationHandler(EnumerationMutationHandlerI handler)
Sets the current mutation handler.- Parameters:
handler- a function pointer to the new mutation handler
-
imp_implementationWithBlock
public static long imp_implementationWithBlock(long block)
Creates a pointer to a function that calls the specified block when the method is called.- Parameters:
block- the block that implements this method. The signature ofblockshould bemethod_return_type ^(id self, self, method_args …). The selector of the method is not available toblock.blockis copied withBlock_copy().- Returns:
- the IMP that calls
block. You must dispose of the returned IMP using the function.
-
imp_getBlock
public static long imp_getBlock(long anImp)
Returns the block associated with an IMP that was created usingObjCRuntime.imp_implementationWithBlock(long).- Parameters:
anImp- the IMP that calls this block- Returns:
- the block called by
anImp
-
imp_removeBlock
public static boolean imp_removeBlock(long anImp)
Disassociates a block from an IMP that was created usingObjCRuntime.imp_implementationWithBlock(long), and releases the copy of the block that was created.- Parameters:
anImp- an IMP that was created using theObjCRuntime.imp_implementationWithBlock(long)function.- Returns:
ObjCRuntime.YESif the block was released successfully; otherwise,ObjCRuntime.NO(for example, the function returnsObjCRuntime.NOif the block was not used to createanImppreviously).
-
objc_loadWeak
public static long objc_loadWeak(PointerBuffer location)
Loads the object referenced by a weak pointer and returns it.This function loads the object referenced by a weak pointer and returns it after retaining and autoreleasing the object. As a result, the object stays alive long enough for the caller to use it. This function is typically used anywhere a
__weakvariable is used in an expression.- Parameters:
location- the address of the weak pointer- Returns:
- the object pointed to by location, or
ObjCRuntime.nilif location isObjCRuntime.nil
-
objc_storeWeak
public static long objc_storeWeak(PointerBuffer location, long obj)
Stores a new value in a__weakvariable.This function is typically used anywhere a
__weakvariable is the target of an assignment.- Parameters:
location- the address of the weak pointerobj- the new object you want the weak pointer to now point to- Returns:
- the value stored in location (that is,
obj)
-
objc_setAssociatedObject
public static void objc_setAssociatedObject(long object, long key, long value, long policy)Sets an associated value for a given object using a given key and association policy.- Parameters:
object- the source object for the associationkey- the key for the associationvalue- the value to associate with the keykeyforobject. PassObjCRuntime.nilto clear an existing association.policy- the policy for the association. One of:ObjCRuntime.OBJC_ASSOCIATION_ASSIGNObjCRuntime.OBJC_ASSOCIATION_RETAIN_NONATOMICObjCRuntime.OBJC_ASSOCIATION_COPY_NONATOMICObjCRuntime.OBJC_ASSOCIATION_RETAINObjCRuntime.OBJC_ASSOCIATION_COPY
-
objc_getAssociatedObject
public static long objc_getAssociatedObject(long object, long key)Returns the value associated with a given object for a given key.- Parameters:
object- the source object for the associationkey- the key for the association- Returns:
- the value associated with the key
keyforobject.
-
objc_removeAssociatedObjects
public static void objc_removeAssociatedObjects(long object)
Removes all associations for a given object.The main purpose of this function is to make it easy to return an object to a "pristine state". You should not use this function for general removal of associations from objects, since it also removes associations that other clients may have added to the object. Typically you should use
ObjCRuntime.objc_setAssociatedObject(long, long, long, long)with aObjCRuntime.nilvalue to clear an association.- Parameters:
object- an object that maintains associated objects
-
-