私の場合、d'n'dを処理する最良の方法は、を介することであることが判明しましたWebArchivePboardType
。それで:
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
// Create image data from webarchive stored in a pasteboard.
NSData *image = [pboard dataForType:WebArchivePboardType];
WebArchive *webArchive = [[WebArchive alloc] initWithData:image];
// Let's see what are we dragging.
for (WebResource *subresource in [webArchive subresources])
{
NSString *mimeType = [subresource MIMEType];
if ([mimeType hasPrefix:expectedMimeTypeStartsWith])
{
NSData *data = [subresource data];
CFDataRef imgData = (CFDataRef)data;
CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData (imgData);
CGImageRef image;
if ([mimeType hasSuffix:@"png"])
{
image = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
}
else if ([mimeType hasSuffix:@"jpeg"])
{
image = CGImageCreateWithJPEGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
}
[self setImage:image imageProperties:nil];
}
}
return YES;
}