Sendind 指针到不同的进程并使用它们?
是否可以通过Mach IPC将指针发送到一个对象,方法是将其转换为int,然后将其转换回对象。这行得通吗?如何才能做到?
我想将 CALayer 对象发送到不同的进程。我认为我无法通过 Mach IPC 发送原始对象。
Is it possible to send a pointer to an object via Mach IPC by casting it into an int and then casting it back into the object. Would that work and how can that be done?
I want to send a CALayer object over to a different process. I don't think I can send raw objects via Mach IPC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是行不通的,因为指针是特定于它们所起源的进程的内存的。如果你发送一个指针到另一个进程,如果你幸运的话,它将指向无效的内存。如果你运气不好,它会指向有效的内存,但指向一个与你想要的完全不同的对象。
That won't work, because pointers are specific to the memory of the process that they originate in. If you send a pointer to a different process, it will point to invalid memory if you're lucky. If you're unlucky it will point to valid memory, but to a completely different object than the one you wanted.