• 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: NSImage + Distributed Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage + Distributed Objects


  • Subject: Re: NSImage + Distributed Objects
  • From: Ofri Wolfus <email@hidden>
  • Date: Sat, 18 Aug 2007 11:17:12 +0300

Or you can do something like this:

@interface CKEvilNSImageDOHack : NSImage
@end

@implementation CKEvilNSImageDOHack

// Replace NSImage
+ (void)load {
	[self poseAsClass:[NSImage class]];
}

// If we were encoded with NSPortCoder, we turn ourself to NSData and encode it.
// Otherwise, fall back to NSImage's original implementation.
- (void)encodeWithCoder:(NSCoder *)encoder {
if ([encoder isKindOfClass:[NSPortCoder class]])
[encoder encodeDataObject:[self TIFFRepresentation]];
else
[super encodeWithCoder:encoder];
}


// If we are decoded with NSPortCoder, we decode our TIFF datd and init with it.
// Otherwise, fall back to NSImage's original implementation.
- (id)initWithCoder:(NSCoder *)decoder {
if ([decoder isKindOfClass:[NSPortCoder class]])
return [self initWithData:[decoder decodeDataObject]];
else
return [super initWithCoder:decoder];
}


// Always return self
- (id)replacementObjectForPortCoder:(NSPortCoder *)aCoder {
	return self;
}

@end

Feel free to copy the above code as is :)

- Ofri

- - - - - - - - - - - - - - - - - - -
http://www.dpompa.com
- - - - - - - - - - - - - - - - - - -


On 14/08/2007, at 07:58, Adam R. Maxwell wrote:


On Aug 13, 2007, at 21:38, James Trankelson wrote:

I've been trying to use distributed objects lately, and have
encountered something I can't seem to understand.

I've got an application that's asking a remote object for an image.
The remote machine is creating the image from a View, and sending this
image back to the requesting machine.

[...]

(I've tried sending both NSImage and NSBitmapImageRep types without luck)

Try sending -[NSImage TIFFRepresentation] instead, which should certainly work. Passing an NSImage directly will not work, but you might be able to archive an NSImage or NSBitmapImageRep with NSArchiver and send that (I haven't tried that technique myself).


--
Adam

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >NSImage + Distributed Objects (From: "James Trankelson" <email@hidden>)
 >Re: NSImage + Distributed Objects (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: How to print with a different NSPrintingOrientation for each page?
  • Next by Date: Re: How to use Automator workflows in a Cocoa application?
  • Previous by thread: Re: NSImage + Distributed Objects
  • Next by thread: NSTextView scroll button problem
  • Index(es):
    • Date
    • Thread