• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Distributed Objects, copying thereof
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Distributed Objects, copying thereof
      • From: "Jim Thomason" <email@hidden>
References: 
 >Distributed Objects, copying thereof (From: "Jim Thomason" <email@hidden>)

  • Prev by Date: KVO/CoreData: Recompute a key when dependent key in relationship target changes?
  • Next by Date: Re: Please advise on memory handling
  • Previous by thread: Distributed Objects, copying thereof
  • Next by thread: Re: Distributed Objects, copying thereof
  • Index(es):
    • Date
    • Thread