objective-c - 什么是 Objective-C 运行时中的类处理程序回调?

标签 objective-c objective-c-runtime

什么是 Objective-C 运行时中的类处理程序回调?根据文档,

objc_getClass is different from objc_lookUpClass in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass does not call the class handler callback.

最佳答案

它似乎是运行时的一个过时功能。在/usr/include/objc/runtime.h 中,您可以在标记为 /* Obsolete functions */ 的部分中找到以下声明:

OBJC_EXPORT void objc_setClassHandler(int (*)(const char *)) OBJC2_UNAVAILABLE;

因此,显然,在 Objective-C 2.0 之前,可以注册一个函数指针来充当类处理程序。我猜参数是类名。它将有机会加载或动态创建命名类。

关于objective-c - 什么是 Objective-C 运行时中的类处理程序回调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57934479/

相关文章:

ios - XCode 9 - 导入#import <objc/runtime.h> 时出错 - 仅适用于模拟器

objective-c - swift : Alternative to . classForCoder()

objective-c - 在纯 Swift 中声明一个协议(protocol) @objc 和让它符合 NSObjectProtocol 有什么区别?

objective-c - class_getClassVariable() 有什么作用?

objective-c - 如何从devicename(UITableViewCell)中的tableview中显示蓝牙支持的服务?

ios - 什么是 NSNotFound 的 float

objective-c - iOS7 和 GameKit 蓝牙

ios - 在 Objective-C 中将自定义类注入(inject)子类继承树

ios - Objective-C对象释放后存在于内存中

c - 是否有适用于 Mac OS X 的未弃用的光栅图形框架?