0

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.

Kristina
  • 15,859
  • 29
  • 111
  • 181
  • Even if this were possible, casting it to `int` would break it anyway, since a pointer is bigger than an `int` on some of the architectures Mac OS X supports. Casting the pointer would lop part of it off, and the receiving process would only receive the other part. Also, you can send Cocoa objects via Cocoa Distributed Objects, which are a higher-level form of IPC than Mach ports. – Peter Hosey Aug 14 '10 at 05:41

1 Answers1

2

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.

JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169