Search code examples
cocoaproxydistributed-objects

Send object instead of proxy via Distributed Objects


I can't solve next problem: I have 2 applications which talk to each other using Distributed Objects. Suppose application A call - (void)updateState:(State *)state method from application B.
@interface State : NSObject <NSCopying, NSCoding>...
When updateState: method called in B app I have NSDistantObject representing sended object instead of State object. In Friday Q&A I found that if object conforms to NSCoding protocol the object should be 'sended' instead of proxy, but, I still receive a proxy. I don't find any info about it in Apple Documentation. Maybe someone does know how can I send object instead of proxy and how Distributed Objects system decide when serialize and send an object and when a proxy?


Solution

  • I found it! Also, you should implement - (id)replacementObjectForPortCoder:(NSPortCoder *)coder in object, which you want to pass through. More about this method you can read in Apple documentation.

    Mystical isBycopy and isByref of NSPortCoder, which Apple refs to documentation, but in last is no info, determined by bycopy and byref method parameters keywords. More about this keywords you can read here.