Objective-C runtime, providing class introspection, protocols and resolution of selectors to the methods.
More...
|
| Foundation Framework |
| Foundational classes and types, including strings, numbers, dates, data and collections.
|
|
| Application Framework |
| Application-related classes and types, including application lifecycle, event handling, display and frames, and hardware interfaces.
|
|
| Network Framework |
| Network-related classes and types, including WiFi adapter management, connection management, data transmission and network protocols.
|
|
|
typedef struct objc_object * | id |
| A pointer to an instance of a class.
|
|
typedef const struct objc_selector * | SEL |
| A pointer to a method selector.
|
|
typedef struct objc_class * | Class |
| A pointer to a class definition.
|
|
typedef id(* | IMP) (id, SEL,...) |
| A pointer to a method implementation.
|
|
typedef struct objc_method * | Method |
| A pointer to a method.
|
|
typedef struct objc_protocol | objc_protocol_t |
| An instance of a protocol.
|
|
typedef bool | BOOL |
| A Boolean value.
|
|
Objective-C runtime, providing class introspection, protocols and resolution of selectors to the methods.
◆ objc_assert
#define objc_assert |
( |
|
condition | ) |
|
Value:if (!(condition)) { \
sys_panicf("ASSERT FAIL: %s", #condition); \
}
Asserts that a condition is true.
- Parameters
-
condition | The condition to check. |
If the DEBUG
macro is defined, this macro will check the given condition. If the condition is false, it will call panicf
with an assertion failure message, including the condition, file name, and line number. If DEBUG
is not defined, this macro does nothing.
- Examples:
- examples/Application/blink/main.m, and examples/Application/timer/main.m.
Definition at line 29 of file assert.h.
◆ OBJC_REQUIRES_NIL_TERMINATION
#define OBJC_REQUIRES_NIL_TERMINATION |
A macro to indicate that a method requires a nil-terminated list of arguments.
This macro is used in method declarations to specify that the method accepts a variable number of arguments that must be terminated with nil
.
Definition at line 109 of file runtime.h.
◆ OBJC_ROOT_CLASS
A macro to declare a class as a root class.
This macro uses the objc_root_class
attribute if it is available, which allows a class to be defined without a superclass.
Definition at line 83 of file runtime.h.
◆ OBJC_UNUSED
A macro to declare a method parameter is unused.
This macro uses the unused
attribute if it is available, which allows a method parameter to be marked as unused.
Definition at line 97 of file runtime.h.
◆ class_conformsTo()
Checks if a class conforms to a protocol.
- Parameters
-
cls | The class to test for conformance. |
otherProtocol | The protocol to check conformance against. |
- Returns
YES
if methods of a cls
conforms to otherProtocol
, NO
otherwise.
◆ class_getInstanceSize()
size_t class_getInstanceSize |
( |
Class |
cls | ) |
|
Returns the size of an instance of a class.
- Parameters
-
- Returns
- The size of an instance of the class in bytes, or 0 if the class is
Nil
.
◆ class_getName()
const char* class_getName |
( |
Class |
cls | ) |
|
Returns the name of a class.
- Parameters
-
- Returns
- A C-string containing the name of the class, or
NULL
if cls
is Nil
.
◆ class_getSuperclass()
Returns the superclass of a class.
- Parameters
-
- Returns
- The superclass of the class, or
Nil
if it is a root class.
◆ class_metaclassRespondsToSelector()
BOOL class_metaclassRespondsToSelector |
( |
Class |
cls, |
|
|
SEL |
sel |
|
) |
| |
Checks if a class object responds to a selector.
- Parameters
-
cls | The class to inspect. |
sel | The selector to check. |
- Returns
YES
if the class responds to the selector, NO
otherwise.
◆ class_respondsToSelector()
Checks if an instance of a class responds to a selector.
- Parameters
-
cls | The class to inspect. |
sel | The selector to check. |
- Returns
YES
if instances of the class respond to the selector, NO
otherwise.
◆ objc_free()
void objc_free |
( |
void * |
ptr | ) |
|
Free memory previously allocated by objc_malloc().
- Parameters
-
ptr | A pointer to the memory block to be deallocated. |
◆ objc_lookupClass()
Class objc_lookupClass |
( |
const char * |
name | ) |
|
Looks up a class by name.
- Parameters
-
name | The name of the class to look up. |
- Returns
- The class object, or
Nil
if the class is not found.
◆ objc_malloc()
void* objc_malloc |
( |
size_t |
size | ) |
|
Allocate memory for use by the Objective-C runtime.
- Parameters
-
size | The number of bytes to allocate. |
- Returns
- A pointer to the allocated memory block, or NULL if allocation fails.
◆ objc_sync_enter()
int objc_sync_enter |
( |
id |
obj | ) |
|
Acquire a lock on the specified object for thread synchronization.
- Parameters
-
obj | The object to lock. Must not be nil. |
- Returns
- 0 on success, or a non-zero error code on failure.
◆ objc_sync_exit()
int objc_sync_exit |
( |
id |
obj | ) |
|
Release a lock on the specified object.
- Parameters
-
- Returns
- 0 on success, or a non-zero error code on failure.
◆ object_getClass()
Returns the class of an object.
- Parameters
-
object | The object to inspect. |
- Returns
- The class of the object, or
Nil
if the object is nil
.
◆ object_getClassName()
const char* object_getClassName |
( |
id |
obj | ) |
|
Returns the name of an object's class.
- Parameters
-
obj | The object to inspect. |
- Returns
- A C-string containing the name of the object's class, or
NULL
if obj
is nil
.
◆ object_getSuperclass()
Class object_getSuperclass |
( |
id |
obj | ) |
|
Returns the superclass of an object.
- Parameters
-
obj | The object to inspect. |
- Returns
- The superclass of the object, or
Nil
if it is a root class.
◆ object_isKindOfClass()
Checks if an instance class matches, or subclass of another class.
- Parameters
-
object | The object to inspect. |
cls | The class to compare against. |
- Returns
YES
if object
class matches or is a subclass of cls
, NO
otherwise.
◆ object_respondsToSelector()
BOOL object_respondsToSelector |
( |
id |
object, |
|
|
SEL |
sel |
|
) |
| |
Checks if an instance's class responds to a selector.
- Parameters
-
object | The object to inspect. |
sel | The selector to check. |
- Returns
YES
if instances of the class respond to the selector, NO
otherwise.
◆ object_setClass()
void object_setClass |
( |
id |
object, |
|
|
Class |
cls |
|
) |
| |
Sets the class of an object.
- Parameters
-
object | The object to modify. |
cls | The new class for the object. |
◆ proto_conformsTo()
Checks if a protocol conforms to another protocol.
- Parameters
-
protocol | The protocol to test for conformance. |
otherProtocol | The protocol to check conformance against. |
- Returns
YES
if protocol
conforms to otherProtocol
, NO
otherwise.
◆ proto_getName()
Returns the name of a protocol.
- Parameters
-
protocol | The protocol to inspect. |
- Returns
- A C-string containing the name of the protocol, or
NULL
if protocol
is NULL
.
◆ sel_getName()
const char* sel_getName |
( |
SEL |
sel | ) |
|
Returns the name of a selector.
- Parameters
-
sel | The selector to inspect. |
- Returns
- A C-string representing the selector's name.