Drag a Image from the Finder to a custom NSView in Swift2

| | August 4, 2015

I subclassed NSView into a Dropzone, placed it into the storyboard and try to drag a image from the Finder into the view.
The app shows a PMPrintWindowController alert that printing is not allowed. I can’t get it working. I just need the pathnames and turn a NSImage from one into another (not the dragged on).

Here is my basic class that should get the draged file. (I striped it down from an NSImageiew Subclass to the basic i can imaging)

import Cocoa

class DropzoneView: NSView {

override func awakeFromNib() {
    // Add drag and drop support

override func drawRect(dirtyRect: NSRect)  {

override func draggingEntered(sender: NSDraggingInfo) -> NSDragOperation  {
    return NSDragOperation.Copy


But I get this error, as soon as the image enters the border of the view.

enter image description here
(Best AppIcon ever)

The Log shows:

2015-08-04 17:14:36.319 mySecretNewApp[14712:498209]   __agent_connection_block_invoke_2: Connection error - Connection invalid
2015-08-04 17:14:36.357 mySecretNewApp[14712:498061] Could not find image named 'GenericPostscriptPrinter'.
2015-08-04 17:14:36.361 mySecretNewApp[14712:498061] Failed to connect (_appIconImage) outlet from (PMPrintWindowController) to (NSImageView): missing setter or instance variable

How can i realise a dropzone for images that my app recognize and return the path name to the image, or the NSData?

Leave a Reply