objc instance finder在运行时查找Objective C类的实例
对象实例查找器在运行时查找 objc 类的实例提供一个具有以下声明的函数:
NSHashTable *find_instances_of_class(Class class, BOOL include_subclasses);
第一个参数应该是一个 Objective-C 类,你想找到它的所有实例。第二个参数指定是否要递归地包含该类的子类。返回一个 NSHashTable 实例,其中包含对所有找到的实例的弱引用。
示例用法:
@implementation TestClass : NSObject
@end
@interface TestClass
@end
TestClass *obj1 = [TestClass new];
NSHashTable *instances = find_instances_of_class([TestClass class], NO);
下载地址
用户评论