开发者

An example of pushing and retrieving of an NSObject's pointer in ObjC from Shared Memory?

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.


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.


Private pasteboard with a name that only your apps know. That's shared memory by other name, and you get free change notifications and stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜