前言
本文權(quán)當(dāng)做API的速查手冊使用.
- objc_
- class_
- object_
- method_
- property_
- protocol_
- ivar_ ,sel_ ,imp_
1.objc_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
objc_getClass 獲取Class對象
objc_getProtocol 獲取某個協(xié)議
objc_getMetaClass 獲取MetaClass對象
objc_copyProtocolList 拷貝在運(yùn)行時中注冊過的協(xié)議列表
objc_allocateClassPair 分配空間,創(chuàng)建類(僅在 創(chuàng)建之后,注冊之前 能夠添加成員變量)
objc_registerClassPair 注冊一個類(注冊后方可使用該類創(chuàng)建對象)
objc_disposeClassPair 注銷某個類
objc_allocateProtocol 開辟空間創(chuàng)建協(xié)議
objc_registerProtocol 注冊一個協(xié)議
objc_constructInstance 構(gòu)造一個實(shí)例對象(ARC下無效)
objc_destructInstance 析構(gòu)一個實(shí)例對象(ARC下無效)
objc_setAssociatedObject 為實(shí)例對象關(guān)聯(lián)對象
objc_getAssociatedObject 獲取實(shí)例對象的關(guān)聯(lián)對象
objc_removeAssociatedObjects 清空實(shí)例對象的所有關(guān)聯(lián)對象
objc_msgSend 發(fā)送ObjC消息
objc_ 系列函數(shù)關(guān)注于宏觀使用,如類與協(xié)議的空間分配,注冊,注銷等操作
2.class_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
class_addIvar 為類添加實(shí)例變量
class_addProperty 為類添加屬性
class_addMethod 為類添加方法
class_addProtocol 為類遵循協(xié)議
class_replaceMethod 替換類某方法的實(shí)現(xiàn)
class_getName 獲取類名
class_isMetaClass 判斷是否為元類
class_getSuperclass 獲取某類的父類
class_setSuperclass 設(shè)置某類的父類
class_getProperty 獲取某類的屬性
class_getInstanceVariable 獲取實(shí)例變量
class_getClassVariable 獲取類變量
class_getInstanceMethod 獲取實(shí)例方法
class_getClassMethod 獲取類方法
class_getMethodImplementation 獲取方法的實(shí)現(xiàn)
class_getInstanceSize 獲取類的實(shí)例的大小
class_respondsToSelector 判斷類是否實(shí)現(xiàn)某方法
class_conformsToProtocol 判斷類是否遵循某協(xié)議
class_createInstance 創(chuàng)建類的實(shí)例
class_copyIvarList 拷貝類的實(shí)例變量列表
class_copyMethodList 拷貝類的方法列表
class_copyProtocolList 拷貝類遵循的協(xié)議列表
class_copyPropertyList 拷貝類的屬性列表
class_系列函數(shù)關(guān)注于類的內(nèi)部,如實(shí)例變量,屬性,方法,協(xié)議等相關(guān)問題
3.object_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
object_copy 對象copy(ARC無效)
object_dispose 對象釋放(ARC無效)
object_getClassName 獲取對象的類名
object_getClass 獲取對象的Class
object_setClass 設(shè)置對象的Class
object_getIvar 獲取對象中實(shí)例變量的值
object_setIvar 設(shè)置對象中實(shí)例變量的值
object_getInstanceVariable 獲取對象中實(shí)例變量的值 (ARC中無效,使用object_getIvar)
object_setInstanceVariable 設(shè)置對象中實(shí)例變量的值 (ARC中無效,使用object_setIvar)
objcet_系列函數(shù)關(guān)注于對象的角度,如實(shí)例變量
4.method_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
method_getName 獲取方法名
method_getImplementation 獲取方法的實(shí)現(xiàn)
method_getTypeEncoding 獲取方法的類型編碼
method_getNumberOfArguments 獲取方法的參數(shù)個數(shù)
method_copyReturnType 拷貝方法的返回類型
method_getReturnType 獲取方法的返回類型
method_copyArgumentType 拷貝方法的參數(shù)類型
method_getArgumentType 獲取方法的參數(shù)類型
method_getDescription 獲取方法的描述
method_setImplementation 設(shè)置方法的實(shí)現(xiàn)
method_exchangeImplementations 替換方法的實(shí)現(xiàn)
method_系列函數(shù)關(guān)注于方法內(nèi)部,如果方法的參數(shù)及返回值類型和方法的實(shí)現(xiàn)
5.property_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
property_getName 獲取屬性名
property_getAttributes 獲取屬性的特性列表
property_copyAttributeList 拷貝屬性的特性列表
property_copyAttributeValue 拷貝屬性中某特性的值
property_系類函數(shù)關(guān)注與屬性*內(nèi)部,如屬性的特性等
6.protocol_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
protocol_conformsToProtocol 判斷一個協(xié)議是否遵循另一個協(xié)議
protocol_isEqual 判斷兩個協(xié)議是否一致
protocol_getName 獲取協(xié)議名稱
protocol_copyPropertyList 拷貝協(xié)議的屬性列表
protocol_copyProtocolList 拷貝某協(xié)議所遵循的協(xié)議列表
protocol_copyMethodDescriptionList 拷貝協(xié)議的方法列表
protocol_addProtocol 為一個協(xié)議遵循另一協(xié)議
protocol_addProperty 為協(xié)議添加屬性
protocol_getProperty 獲取協(xié)議中的某個屬性
protocol_addMethodDescription 為協(xié)議添加方法描述
protocol_getMethodDescription 獲取協(xié)議中某方法的描述
7.ivar_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
ivar_getName 獲取Ivar名稱
ivar_getTypeEncoding 獲取類型編碼
ivar_getOffset 獲取偏移量
8.sel_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
sel_getName 獲取名稱
sel_getUid 注冊方法
sel_registerName 注冊方法
sel_isEqual 判斷方法是否相等
9.imp_xxx 系列函數(shù)
函數(shù)名稱 函數(shù)作用
imp_implementationWithBlock 通過代碼塊創(chuàng)建IMP
imp_getBlock 獲取函數(shù)指針中的代碼塊
imp_removeBlock 移除IMP中的代碼塊
轉(zhuǎn)載自:這里