Cocoa Distributed Objects are Too Easy!
A little background information: The post below I talked about creating iFishes, the Mac memory editor application. The big hurdle during the process of writing this application has been that in order to search another application’s memory, it must be run as root. And I’m not crazy enough to request a user for permission to run the entire iFishes application as root (too many security risks)!! So I cleverly (if I do say so myself) split the program into two, with one utility which runs as a background process which handles all the memory searching (and runs as root). The problem which this introduces is one which, coming from a windows world, is non-trivial: Interprocess Communication.
I immediately turned to Apple’s amazing developer portal for guidance. I was given a nicely formatted list of available options for process communication such as BSD sockets, shared memory, etc. It noted that if you’re using Cocoa, Distributed Objects is the way to go! So, trusting Apple, I said “Okay!”
Now let me say: Distributed objects are the coolest things ever. I said it. I usually try to stay away from absolute statements such as that, but it’s true. (Well to be honest, I would say they are on the same level as Core Animation)
Basically, distributed objects allow one process to “vend” one of it’s objects. Then another process can receive this vended object and use it as if it were in the same memory space! Example:
Process A has an object:
@interface MyObject : NSObject {} - (void)someMethod; @end
Let’s assume Process A “vends” this object. And that Process B receives this object. Now somewhere in process B it can just do this:
- (void)someRandomMethod { // Assuming distantObject is an instance variable created earlier from the vended // object from Process A [distantObject someMethod]; }
That’s it!!! Cocoa handles all the underlying messaging between the processes. Amazing. AMAZING.

