---
title: Objective-C Runtime
framework: Objective-C Runtime
role: collectionGroup
role_heading: API Collection
path: objectivec/objective-c-runtime
---

# Objective-C Runtime

Describes the macOS Objective-C runtime library support functions and data structures.

## Overview

Overview The Objective-C runtime is a runtime library that provides support for the dynamic properties of the Objective-C language, and as such is linked to by all Objective-C apps. Objective-C runtime library support functions are implemented in the shared library found at /usr/lib/libobjc.A.dylib. You typically don’t need to use the Objective-C runtime library directly when programming in Objective-C. This API is useful primarily for developing bridge layers between Objective-C and other languages, or for low-level debugging. The macOS implementation of the Objective-C runtime library is unique to the Mac. For other platforms, the GNU Compiler Collection provides a different implementation with a similar API. This document covers only the macOS implementation. The low-level Objective-C runtime API is significantly updated in OS X version 10.5. Many functions and all existing data structures are replaced with new functions. The old functions and structures are deprecated in 32-bit and absent in 64-bit mode. The API constrains several values to 32-bit ints even in 64-bit mode—class count, protocol count, methods per class, ivars per class, arguments per method, sizeof(all arguments) per method, and class version number. In addition, the new Objective-C ABI (not described here) further constrains sizeof(anInstance) to 32 bits, and three other values to 24 bits—methods per class, ivars per class, and sizeof(a single ivar). Finally, the obsolete NXHashTable and NXMapTable are limited to 4 billion items. note: All char * in the runtime API should be considered to have UTF-8 encoding. “Deprecated” below means “deprecated in OS X version 10.5 for 32-bit code, and disallowed for 64-bit code.” Who Should Read This Document The document is intended for readers who might be interested in learning about the Objective-C runtime. Because this isn’t a document about C, it assumes some prior acquaintance with that language. However, it doesn’t have to be an extensive acquaintance.

## Topics

### Working with Classes

- [class_getName(_:)](objectivec/class_getname(_:).md)
- [class_getSuperclass(_:)](objectivec/class_getsuperclass(_:).md)
- [class_setSuperclass(_:_:)](objectivec/class_setsuperclass(_:_:).md)
- [class_isMetaClass(_:)](objectivec/class_ismetaclass(_:).md)
- [class_getInstanceSize(_:)](objectivec/class_getinstancesize(_:).md)
- [class_getInstanceVariable(_:_:)](objectivec/class_getinstancevariable(_:_:).md)
- [class_getClassVariable(_:_:)](objectivec/class_getclassvariable(_:_:).md)
- [class_addIvar(_:_:_:_:_:)](objectivec/class_addivar(_:_:_:_:_:).md)
- [class_copyIvarList(_:_:)](objectivec/class_copyivarlist(_:_:).md)
- [class_getIvarLayout(_:)](objectivec/class_getivarlayout(_:).md)
- [class_setIvarLayout(_:_:)](objectivec/class_setivarlayout(_:_:).md)
- [class_getWeakIvarLayout(_:)](objectivec/class_getweakivarlayout(_:).md)
- [class_setWeakIvarLayout(_:_:)](objectivec/class_setweakivarlayout(_:_:).md)
- [class_getProperty(_:_:)](objectivec/class_getproperty(_:_:).md)
- [class_copyPropertyList(_:_:)](objectivec/class_copypropertylist(_:_:).md)
- [class_addMethod(_:_:_:_:)](objectivec/class_addmethod(_:_:_:_:).md)
- [class_getInstanceMethod(_:_:)](objectivec/class_getinstancemethod(_:_:).md)
- [class_getClassMethod(_:_:)](objectivec/class_getclassmethod(_:_:).md)
- [class_copyMethodList(_:_:)](objectivec/class_copymethodlist(_:_:).md)
- [class_replaceMethod(_:_:_:_:)](objectivec/class_replacemethod(_:_:_:_:).md)
- [class_getMethodImplementation(_:_:)](objectivec/class_getmethodimplementation(_:_:).md)
- [class_getMethodImplementation_stret(_:_:)](objectivec/class_getmethodimplementation_stret(_:_:).md)
- [class_respondsToSelector(_:_:)](objectivec/class_respondstoselector(_:_:).md)
- [class_addProtocol(_:_:)](objectivec/class_addprotocol(_:_:).md)
- [class_addProperty(_:_:_:_:)](objectivec/class_addproperty(_:_:_:_:).md)
- [class_replaceProperty(_:_:_:_:)](objectivec/class_replaceproperty(_:_:_:_:).md)
- [class_conformsToProtocol(_:_:)](objectivec/class_conformstoprotocol(_:_:).md)
- [class_copyProtocolList(_:_:)](objectivec/class_copyprotocollist(_:_:).md)
- [class_getVersion(_:)](objectivec/class_getversion(_:).md)
- [class_setVersion(_:_:)](objectivec/class_setversion(_:_:).md)
- [objc_setFutureClass](objectivec/1808430-objc_setfutureclass.md)

### Adding Classes

- [objc_allocateClassPair(_:_:_:)](objectivec/objc_allocateclasspair(_:_:_:).md)
- [objc_disposeClassPair(_:)](objectivec/objc_disposeclasspair(_:).md)
- [objc_registerClassPair(_:)](objectivec/objc_registerclasspair(_:).md)
- [objc_duplicateClass(_:_:_:)](objectivec/objc_duplicateclass(_:_:_:).md)

### Instantiating Classes

- [class_createInstance(_:_:)](objectivec/class_createinstance(_:_:).md)

### Working with Instances

- [object_getIndexedIvars(_:)](objectivec/object_getindexedivars(_:).md)
- [object_getIvar(_:_:)](objectivec/object_getivar(_:_:).md)
- [object_setIvar(_:_:_:)](objectivec/object_setivar(_:_:_:).md)
- [object_getClassName(_:)](objectivec/object_getclassname(_:).md)
- [object_getClass(_:)](objectivec/object_getclass(_:).md)
- [object_setClass(_:_:)](objectivec/object_setclass(_:_:).md)

### Obtaining Class Definitions

- [objc_getClassList(_:_:)](objectivec/objc_getclasslist(_:_:).md)
- [objc_copyClassList(_:)](objectivec/objc_copyclasslist(_:).md)
- [objc_lookUpClass(_:)](objectivec/objc_lookupclass(_:).md)
- [objc_getClass(_:)](objectivec/objc_getclass(_:).md)
- [objc_getRequiredClass(_:)](objectivec/objc_getrequiredclass(_:).md)
- [objc_getMetaClass(_:)](objectivec/objc_getmetaclass(_:).md)

### Working with Instance Variables

- [ivar_getName(_:)](objectivec/ivar_getname(_:).md)
- [ivar_getTypeEncoding(_:)](objectivec/ivar_gettypeencoding(_:).md)
- [ivar_getOffset(_:)](objectivec/ivar_getoffset(_:).md)

### Associative References

- [objc_setAssociatedObject(_:_:_:_:)](objectivec/objc_setassociatedobject(_:_:_:_:).md)
- [objc_getAssociatedObject(_:_:)](objectivec/objc_getassociatedobject(_:_:).md)
- [objc_removeAssociatedObjects(_:)](objectivec/objc_removeassociatedobjects(_:).md)

### Working with Methods

- [method_getName(_:)](objectivec/method_getname(_:).md)
- [method_getImplementation(_:)](objectivec/method_getimplementation(_:).md)
- [method_getTypeEncoding(_:)](objectivec/method_gettypeencoding(_:).md)
- [method_copyReturnType(_:)](objectivec/method_copyreturntype(_:).md)
- [method_copyArgumentType(_:_:)](objectivec/method_copyargumenttype(_:_:).md)
- [method_getReturnType(_:_:_:)](objectivec/method_getreturntype(_:_:_:).md)
- [method_getNumberOfArguments(_:)](objectivec/method_getnumberofarguments(_:).md)
- [method_getArgumentType(_:_:_:_:)](objectivec/method_getargumenttype(_:_:_:_:).md)
- [method_getDescription(_:)](objectivec/method_getdescription(_:).md)
- [method_setImplementation(_:_:)](objectivec/method_setimplementation(_:_:).md)
- [method_exchangeImplementations(_:_:)](objectivec/method_exchangeimplementations(_:_:).md)

### Working with Libraries

- [objc_copyImageNames(_:)](objectivec/objc_copyimagenames(_:).md)
- [class_getImageName(_:)](objectivec/class_getimagename(_:).md)
- [objc_copyClassNamesForImage(_:_:)](objectivec/objc_copyclassnamesforimage(_:_:).md)

### Working with Selectors

- [sel_getName(_:)](objectivec/sel_getname(_:).md)
- [sel_registerName(_:)](objectivec/sel_registername(_:).md)
- [sel_getUid(_:)](objectivec/sel_getuid(_:).md)
- [sel_isEqual(_:_:)](objectivec/sel_isequal(_:_:).md)

### Working with Protocols

- [objc_getProtocol(_:)](objectivec/objc_getprotocol(_:).md)
- [objc_copyProtocolList(_:)](objectivec/objc_copyprotocollist(_:).md)
- [objc_allocateProtocol(_:)](objectivec/objc_allocateprotocol(_:).md)
- [objc_registerProtocol(_:)](objectivec/objc_registerprotocol(_:).md)
- [protocol_addMethodDescription(_:_:_:_:_:)](objectivec/protocol_addmethoddescription(_:_:_:_:_:).md)
- [protocol_addProtocol(_:_:)](objectivec/protocol_addprotocol(_:_:).md)
- [protocol_addProperty(_:_:_:_:_:_:)](objectivec/protocol_addproperty(_:_:_:_:_:_:).md)
- [protocol_getName(_:)](objectivec/protocol_getname(_:).md)
- [protocol_isEqual(_:_:)](objectivec/protocol_isequal(_:_:).md)
- [protocol_copyMethodDescriptionList(_:_:_:_:)](objectivec/protocol_copymethoddescriptionlist(_:_:_:_:).md)
- [protocol_getMethodDescription(_:_:_:_:)](objectivec/protocol_getmethoddescription(_:_:_:_:).md)
- [protocol_copyPropertyList(_:_:)](objectivec/protocol_copypropertylist(_:_:).md)
- [protocol_getProperty(_:_:_:_:)](objectivec/protocol_getproperty(_:_:_:_:).md)
- [protocol_copyProtocolList(_:_:)](objectivec/protocol_copyprotocollist(_:_:).md)
- [protocol_conformsToProtocol(_:_:)](objectivec/protocol_conformstoprotocol(_:_:).md)

### Working with Properties

- [property_getName(_:)](objectivec/property_getname(_:).md)
- [property_getAttributes(_:)](objectivec/property_getattributes(_:).md)
- [property_copyAttributeValue(_:_:)](objectivec/property_copyattributevalue(_:_:).md)
- [property_copyAttributeList(_:_:)](objectivec/property_copyattributelist(_:_:).md)

### Using Objective-C Language Features

- [objc_enumerationMutation(_:)](objectivec/objc_enumerationmutation(_:).md)
- [objc_setEnumerationMutationHandler(_:)](objectivec/objc_setenumerationmutationhandler(_:).md)
- [imp_implementationWithBlock(_:)](objectivec/imp_implementationwithblock(_:).md)
- [imp_getBlock(_:)](objectivec/imp_getblock(_:).md)
- [imp_removeBlock(_:)](objectivec/imp_removeblock(_:).md)
- [objc_loadWeak(_:)](objectivec/objc_loadweak(_:).md)
- [objc_storeWeak(_:_:)](objectivec/objc_storeweak(_:_:).md)

### Class-Definition Data Structures

- [Method](objectivec/method.md)
- [Ivar](objectivec/ivar.md)
- [Category](objectivec/category.md)
- [objc_property_t](objectivec/objc_property_t.md)
- [IMP](objectivec/imp.md)
- [objc_method_description](objectivec/objc_method_description.md)
- [objc_cache](objectivec/objc_cache.md)
- [objc_property_attribute_t](objectivec/objc_property_attribute_t.md)

### Instance Data Types

- [objc_object](objectivec/objc_object.md)
- [objc_super](objectivec/objc_super-swift.struct.md)

### Associative References

- [objc_AssociationPolicy](objectivec/objc_associationpolicy.md)

## See Also

### Related Documentation

- [Objective-C Runtime Programming Guide](apple-archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Introduction.md)

### Reference

- [Objective-C Structures](objectivec/objective-c-structures.md)
- [Objective-C Constants](objectivec/objective-c-constants.md)
- [Objective-C Functions](objectivec/objective-c-functions.md)
- [Objective-C Data Types](objectivec/objective-c-data-types.md)
- [Objective-C Macros](objectivec/objective-c-macros.md)
- [Objective-C Enumerations](objectivec/objective-c-enums.md)
