Sendind 指针到不同的进程并使用它们?

发布于 2024-09-14 10:41:18 字数 167 浏览 3 评论 0原文

是否可以通过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2024-09-21 10:41:18

这是行不通的,因为指针是特定于它们所起源的进程的内存的。如果你发送一个指针到另一个进程,如果你幸运的话,它将指向无效的内存。如果你运气不好,它会指向有效的内存,但指向一个与你想要的完全不同的对象。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文