This document describes the OS X Objective-C 2.0 runtime library support functions and data structures. The functions are implemented in the shared library found at /usr/lib/libobjc.A.dylib. This shared library provides support for the dynamic properties of the Objective-C language, and as such is linked to by all Objective-C applications.

This reference is useful primarily for developing bridge layers between Objective-C and other languages, or for low-level debugging. You typically do not need to use the Objective-C runtime library directly when programming in Objective-C.

The OS X 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 OS X 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.

STRING ENCODING

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.

Functions

Working with Instance Variables

Sending Messages

When it encounters a method invocation, the compiler might generate a call to any of several functions to perform the actual message dispatch, depending on the receiver, the return value, and the arguments. You can use these functions to dynamically invoke methods from your own plain C code, or to use argument forms not permitted by NSObject’s perform... methods. These functions are declared in/usr/include/objc/objc-runtime.h.

  • objc_msgSend sends a message with a simple return value to an instance of a class.

  • objc_msgSend_stret sends a message with a data-structure return value to an instance of a class.

  • objc_msgSendSuper sends a message with a simple return value to the superclass of an instance of a class.

  • objc_msgSendSuper_stret sends a message with a data-structure return value to the superclass of an instance of a class.

Data Types

Instance Data Types

These are the data types that represent objects, classes, and superclasses.

  • id pointer to an instance of a class.

  • objc_object represents an instance of a class.

  • objc_super specifies the superclass of an instance.

Boolean Value

Associative References

Constants

Objective-C Runtime Reference的更多相关文章

  1. Objective C Runtime 开发介绍

    简介 Objective c 语言尽可能的把决定从编译推迟到链接到运行时.只要可能,它就会动态的处理事情.这就意味着它不仅仅需要一个编译器,也需要一个运行时系统来执行变异好的代码.运行时系统就好像是O ...

  2. Objective C运行时(runtime)

    #import <objc/runtime.h> void setBeingRemoved(id __self, SEL _cmd) { NSLog(@"------------ ...

  3. Objective C运行时(runtime)技术的几个要点总结

    前言:          Objective C的runtime技术功能非常强大,能够在运行时获取并修改类的各种信息,包括获取方法列表.属性列表.变量列表,修改方法.属性,增加方法,属性等等,本文对相 ...

  4. 刨根问底Objective-C Runtime(4)- 成员变量与属性

    http://chun.tips/blog/2014/11/08/bao-gen-wen-di-objective[nil]c-runtime(4)[nil]-cheng-yuan-bian-lian ...

  5. iOS开发——高级特性&Runtime运行时特性详解

    Runtime运行时特性详解 本文详细整理了 Cocoa 的 Runtime 系统的知识,它使得 Objective-C 如虎添翼,具备了灵活的动态特性,使这门古老的语言焕发生机.主要内容如下: 引言 ...

  6. Objective-C Runtime(转)

    博主地址: http://yulingtianxia.com/blog/2014/11/05/objective-c-runtime/ 曾经觉得Objc特别方便上手,面对着 Cocoa 中大量 API ...

  7. iOS 开发-- Runtime 1小时入门教程

    1小时让你知道什么是Objective-C Runtime,并对它有一定的基本了解,可以在开发过程中运用自如. 三.Objective-C Runtime到底是什么东西? 简而言之,Objective ...

  8. Objective-C:runtime

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  9. 全方位分析Objcetive-C Runtime

    本文详细整理了 Cocoa 的 Runtime 系统的知识,它使得 Objective-C 如虎添翼,具备了灵活的动态特性,使这门古老的语言焕发生机.主要内容如下: 引言 简介 与Runtime交互 ...

随机推荐

  1. HDU2896(AC自动机入门题)

    病毒侵袭 Time Limit:1000MS     Memory Limit:32768KB   Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这 ...

  2. cobbler api

    try: import xmlrpclib except ImportError as e: import xmlrpc.client SERVER_IP = '192.168.144.11' try ...

  3. TQ210 —— S5PV210 uboot顶层Makefile分析

    转自:http://blog.csdn.net/wqx521/article/details/52469759 # (C) Copyright 2000-2008 # Wolfgang Denk, D ...

  4. 2.对《30个提高Web程序执行效率的好经验》的理解

    摘自:http://www.cnblogs.com/powertoolsteam/archive/2010/07/12/1775933.html 文章中执行代码的消耗时间是怎么计算的,有知道的同学可以 ...

  5. 20个Flutter实例视频教程-第13节: 展开闭合案例

    20个Flutter实例视频教程-第13节: 展开闭合案例 视频地址: https://www.bilibili.com/video/av39709290/?p=13 博客地址: https://js ...

  6. 4-1逻辑与运算符介绍 & 4-2逻辑或运算符介绍

    后面括号内的(n++)不运算了. 4-2逻辑或运算符介绍

  7. QDUOJ LC的课后辅导 单调递增栈

    LC的课后辅导 发布时间: 2015年9月19日 21:42   时间限制: 1000ms   内存限制: 256M 描述 有一天,LC给我们出了一道题,如图: 这个图形从左到右由若干个 宽为1 高不 ...

  8. Atom 基本使用

    插件 simplified-Chinese-menu:汉化 Markdown-preview-plus:Markdown 实时预览 Atom 自带 Markdown-preview,这个插件是其增强版 ...

  9. Codeforces 358D【DP】

    思路:  dp[i][0] 代表取的时候左边没有 dp[i][1] 代表取的时候右边没有 dp[i][2] 代表取的时候左右都没有 dp[i][3] 代表取的时候左右都有 然后自己转移吧= =. 注意 ...

  10. PHP在cli模式下传参说明

    命令行下输入php -help会列出所有可用的参数,如下截图: -a 代表以交互式模式运行: -c 指定ph.ini -n 不使用任何php.ini配置 -d foo[=bar] 定义一个INI实体, ...