views:

41

answers:

1

I know that there are better ways of sharing objects such as distributed objects but my situation is quite difficult. I'm working on two iPhone apps which are running parallely and need to share an object. That object happens to be a CALayer and it needs to be accessible by both applications. Second application adds its own CALayer to the first app's CALayer and does its work there.

The only way I see is using Shared Memory, but I couldn't find any useful examples of doing exactly what I need. Could someone demonstrate pushing the pointer into shared memory, then retrieving it and serializing it back into the CALayer object?

P.S.: I am aware of the AppStore policies and I don't need another lecture regarding them.

A: 

From Memory Usage Performance Guidelines:

The functions used to create and manage shared memory regions are in the /usr/include/sys/shm.h header file.

See also mmap(2), shmctl(2), shmget(2), compat(5)

Don't expect to find a lot of examples for this. This isn't something that is used very often these days. It's old school BSD and plain C. It will only work on a jailbroke device. You'd be better off looking under plain Unix or even Linux resources than Apple API specifically.

TechZen