Re: Problems with Distributed Objects
Re: Problems with Distributed Objects
- Subject: Re: Problems with Distributed Objects
- From: Philippe Mougin <email@hidden>
- Date: Thu, 26 Feb 2004 21:16:02 +0100
>
Implementing that method does indeed give me an AMTickerSign ...
>
but its image instance variable is still an NSDistantObject!
>
How am I supposed to change that? Declaring a category to
>
NSImage? Is that really how it is supposed to work?
Implementing replacementObjectForPortCoder: in a category of NSImage
might do the trick. However, it would be much cleaner to subclass
NSImage, implement the method in your subclass and use that subclass in
your code.
But there are less intrusive paths.
In the encodeWithCoder: method of your custom object, instead of asking
your image to encode itself, get the data out of your image into an
NSData object (for instance, using the TIFFRepresentation method). Then
encode this NSData object instead of your image. By default, NSData
objects pass themselves by value over a distributed object connection.
In your initWithCoder: decode the NSData object and construct a new
NSImage object with it (using the initWithData: method).
Another solution, which is simpler but require one additional
interaction between the client and the server, is to just modify your
current initWithCoder: method. Ask the NSDistantObject standing for
your image to give you its data (for instance using the
TIFFRepresentation method). Then construct a local NSImage object with
this data.
Best,
Philippe Mougin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.