Re: Distributed Objects, copying thereof
Re: Distributed Objects, copying thereof
- Subject: Re: Distributed Objects, copying thereof
- From: John Pannell <email@hidden>
- Date: Thu, 8 Jun 2006 10:49:02 -0600
Hi Jim-
On Jun 8, 2006, at 10:23 AM, Jim Thomason wrote:
In short, I need to pass some NSImages and NSBezierPaths around from
clients to the server.
To send an object "across the wire" in DO, your object needs to
implement the NSCoding protocol. As an additional note (that I didn't
encounter in Apple docs), the object that does the coding in DO
(NSPortCoder, I believe) does not seem to support keyed coding, so be
sure your encodeWithCoder: and initWithCoder: methods are old school,
and not keyed.
Your object also needs to also implement the following method, in
order to tell the NSPortCoder to package up and send your actual
object contents, not just a reference to the object:
- (id)replacementObjectForPortCoder:(NSPortCoder *)encoder {
if ([encoder isByref]){
return [NSDistantObject proxyWithLocal:self connection:
[encoder connection]];
} else {
return self;
}
}
Finally, make sure the appropriate method signature specifies the
"bycopy" keyword. The NSPortCoder checks this to see what to send.
If you've got this in place, you don't need to monkey with prepping
new objects to send - DO will take care of things for you, and your
messaging looks just like it would without DO (i.e.
[someDistantObject setImage:someLocalImage]). DO mechanics will
package up the image, send a copy across the wire, and unpack it on
the other end.
HTH!
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden