获取指向对象的所有现有指针
是否有可能获得指向目标 c 对象的指针的指针列表。
有点
id **pointers(id object, int *out_count)
疯狂,是吧? =)
Is it possible to get a list of pointer to a pointers to an objective c object.
something like
id **pointers(id object, int *out_count)
Pretty crazy, huh? =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,没有。如果这样的事情通常是可能的,那么编写一个精确的垃圾收集器将相当简单:
由于 Objective-C 垃圾收集器必须从根追踪指针,控制分配器,并保守地扫描堆栈以实现类似的目标,我认为可以合理地假设您也需要这样做。
不过,如果在 GC 模式下运行,则可以利用垃圾收集器的实现。这不是一个好主意,也不简单,而且不适用于 iOS,但也许是可能的。 libauto 毕竟是开源的。
Unfortunately, no. If such a thing were generally possible, then writing a precise garbage collector would be rather simple:
Since the objective-c garbage collector has to chase pointers from roots, control the allocator, and scan the stack conservatively to achieve something like this, I think it's reasonable to assume that you'd need to do the same.
It might be possible to leverage the garbage collector's implementation of this, though, if running in GC mode. Not a good idea, not simple, and won't work on iOS, but maybe possible. libauto is open source after all.