One Quickie

Grabbing a view into an image (NSView->General)
In your NSView subclass:
[self lockFocus];

NSBitmapImageRep *bits;
bits = [[NSBitmapImageRep alloc]
           initWithFocusedViewRect: [self bounds]];
[self unlockFocus];
Then you can add it to an NSImage or save it to a file, or whatever.

If you want to retain the vectoritude of the drawing, you can use [self dataWithPDFInsideRect: [self bounds]], and then make an NSPDFImageRep. Avoid the NSEPSImageRep since it makes a trip through NSPDFImageRep along with a slow PS to PDF conversion. (Thanks to Peter Hosey for the PDF hint)

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book