I\'ve studied Apple\'s example: CocoaDragAndDrop. I understand how to drag a image to NSImageView and drag an image between views. However, I still don\'t known how to drag
-(IBAction)saveImageButtonPushed:(id)sender
{
NSLog(@"saveImageButtonPushed");
NSBitmapImageRep *rep;
NSData *data;
NSImage *image;
[self lockFocus];
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[self frame]];
[self unlockFocus];
image = [[[NSImage alloc] initWithSize:[rep size]] autorelease];
[image addRepresentation:rep];
data = [rep representationUsingType: NSPNGFileType properties: nil];
//save as png but failed
[data writeToFile: @"asd.png" atomically: NO];
//save as pdf, succeeded but with flaw
data = [self dataWithPDFInsideRect:[self frame]];
[data writeToFile:@"asd.pdf" atomically:YES];
}
//......
@end