Last active
November 21, 2019 12:09
-
-
Save qy1010/e4f9b6aea5979bb374717f07c3a81ef8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
对对象类的操作: | |
// 返回给定对象的类名 | |
const char * object_getClassName ( id obj ); | |
// 返回对象的类 | |
Class object_getClass ( id obj ); | |
// 设置对象的类 | |
Class object_setClass ( id obj, Class cls ); | |
获取对象的类定义 | |
// 获取已注册的类定义的列表 | |
int objc_getClassList ( Class *buffer, int bufferCount ); | |
// 创建并返回一个指向所有已注册类的指针列表 | |
Class * objc_copyClassList ( unsigned int *outCount ); | |
// 返回指定类的类定义 | |
Class objc_lookUpClass ( const char *name ); | |
Class objc_getClass ( const char *name ); | |
Class objc_getRequiredClass ( const char *name ); | |
// 返回指定类的元类 | |
Class objc_getMetaClass ( const char *name ); | |
动态创建对象 | |
// 创建类实例 | |
id class_createInstance ( Class cls, size_t extraBytes ); //会在heap里给类分配内存。这个方法和+alloc方法类似。 | |
// 在指定位置创建类实例 | |
id objc_constructInstance ( Class cls, void *bytes ); | |
// 销毁类实例 | |
void * objc_destructInstance ( id obj ); //不会释放移除任何相关引用 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment