I have been able to figure out the problem myself. Here is the solution for anyone interested.
To diagnose the problem, I tried to send a test object bycopy to the server, instead of receiving an object bycopy from the server. It allowed me to locally debug what's happening when -replacementObjectForPortCoder: is called. The problem was that I used NSCoder's -[encode***: forKey:], whereas it turns out that the NSPortCoder does not support it, so an exception occurred. It only supports encoding C-types -encodeValueOfObjCType:at:, -encodeValuesOfObjCTypes:..., -encodeArrayOfObjCType:count:at:, -encodeObject: and their decode* counterparts. The last encodeObject/decodeObject method processes object members recursively. For my application it's okay to not use keys in encoding/decoding, so it solved the problem. Oleg. On Mon, Oct 18, 2010 at 6:46 PM, Oleg Krupnov <[email protected]> wrote: > Hi, > > I have a server and a client processes running on the same machine. > Per client request, the server does some job and returns the result to > the client in form of some MyObject. > > This is the interface vended by the server: > > - (out bycopy MyObject*)doSomeJob; > > Despite bycopy, I see in debugger that instead of a copy, a proxy is returned. > > Allright, I've read in this list that in order to make work, I also > need to override -replacementObjectForPortCoder: and I did this: > > // in MyObject > - (id)replacementObjectForPortCoder:(NSPortCoder*)encoder > { > if ([encoder isBycopy]) > { > NSLog(@"replace by copy!!!") > return self; > } > return [super replacementObjectForPortCoder:encoder]; > } > > In this case, I see the "replace by copy!!!" string in the console, > but then the server process seems to hang and become unresponsive. > -[MyObject encodeWithCoder:] does not get called. > > What am I doing wrong? > > Thanks! > _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
