美文网首页
runtime(0)

runtime(0)

作者: 初灬终 | 来源:发表于2017-12-04 01:00 被阅读9次

待补充!

1.struct

typedef struct objc_method *Method; 
typedef struct objc_ivar *Ivar;
typedef struct objc_category *Category;
typedef struct objc_property *objc_property_t;
typedef struct objc_object Protocol;
struct objc_class

2.class

1.获取类名

OBJC_EXPORT const char * _Nonnull 
class_getName(Class _Nullable cls) 

2.释放指定对象的内存

OBJC_EXPORT id _Nullable
object_dispose(id _Nullable obj)

3.获取某个对象的类

OBJC_EXPORT Class _Nullable
object_getClass(id _Nullable obj) 

4.为某个对象指定类

OBJC_EXPORT Class _Nullable
object_setClass(id _Nullable obj, Class _Nonnull cls) 

2.method

1.获取方法名

OBJC_EXPORT SEL _Nonnull
method_getName(Method _Nonnull m) 

2.获取指定对象的指定对象方法

OBJC_EXPORT Method _Nullable
class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name)

3.获取指定类的指定类方法

OBJC_EXPORT Method _Nullable
class_getClassMethod(Class _Nullable cls, SEL _Nonnull name)

4.获取方法的实现IMP

OBJC_EXPORT IMP _Nonnull
method_getImplementation(Method _Nonnull m) 

5.指定class的对象,是否响应指定方法

OBJC_EXPORT BOOL
class_respondsToSelector(Class _Nullable cls, SEL _Nonnull sel) 

6.获取指定class的所有对象方法

OBJC_EXPORT Method _Nonnull * _Nullable
class_copyMethodList(Class _Nullable cls, unsigned int * _Nullable outCount) 

7.为指定方法设置IMP

OBJC_EXPORT IMP _Nonnull
method_setImplementation(Method _Nonnull m, IMP _Nonnull imp) 

8.为指定class添加方法

OBJC_EXPORT BOOL
class_addMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, 
                const char * _Nullable types) 

9.替换某个类的方法实现

OBJC_EXPORT IMP _Nullable
class_replaceMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, 
                    const char * _Nullable types) 

3.property

1.获取属性名

OBJC_EXPORT const char * _Nonnull
property_getName(objc_property_t _Nonnull property) 

2.获取指定类的指定属性

OBJC_EXPORT objc_property_t _Nullable
class_getProperty(Class _Nullable cls, const char * _Nonnull name)

3.获取指定类的所有属性

OBJC_EXPORT objc_property_t _Nonnull * _Nullable
class_copyPropertyList(Class _Nullable cls, unsigned int * _Nullable outCount)

4.为某个类增加属性

class_addProperty(Class _Nullable cls, const char * _Nonnull name,
                  const objc_property_attribute_t * _Nullable attributes,
                  unsigned int attributeCount)

5.替换某个类的属性

OBJC_EXPORT void
class_replaceProperty(Class _Nullable cls, const char * _Nonnull name,
                      const objc_property_attribute_t * _Nullable attributes,
                      unsigned int attributeCount)

4.ivar

1.获取变量名

OBJC_EXPORT const char * _Nullable
ivar_getName(Ivar _Nonnull v) 

2.获取类中所有变量

OBJC_EXPORT Ivar _Nonnull * _Nullable
class_copyIvarList(Class _Nullable cls, unsigned int * _Nullable outCount) 

3.为指定类增加ivar

OBJC_EXPORT BOOL
class_addIvar(Class _Nullable cls, const char * _Nonnull name, size_t size, 
              uint8_t alignment, const char * _Nullable types) 

5.protocol

1.获取协议名

OBJC_EXPORT const char * _Nonnull
protocol_getName(Protocol * _Nonnull proto)

2.判断指定类是否遵守指定协议

OBJC_EXPORT BOOL
class_conformsToProtocol(Class _Nullable cls, Protocol * _Nullable protocol) 

3.获取某个类的所有协议

OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable 
class_copyProtocolList(Class _Nullable cls, unsigned int * _Nullable outCount)

4.为指定类增加协议

OBJC_EXPORT BOOL
class_addProtocol(Class _Nullable cls, Protocol * _Nonnull protocol) 

相关文章

网友评论

      本文标题:runtime(0)

      本文链接:https://www.haomeiwen.com/subject/qwqtixtx.html