views:

23

answers:

1

hi--

my goal is to send an NSView over the wire. i was wondering whether there was a way to get the raw display data contained in an NSView so that I can send this data over the wire and re-display this at the destination.

thanks.

A: 

Jeff LaMarche posted a brief tidbit about this on his blog a while ago:

http://iphonedevelopment.blogspot.com/2008/10/getting-contents-of-uiview-as-uiimage.html

He links to this pastie which contains:

UIGraphicsBeginImageContext(myView.bounds.size);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

That will apparently convert myView in a UIImage called viewImage that you can then convert to an NSData and transmit how you like.

Dave DeLong