Whenever multiple objects are written to pasteboard using the writeObjects method of NSPasteboard an exception is thrown:
2018-08-25 22:41:46.006537+0200 DragTest[24732:2097487] [General] There are 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem.
2018-08-25 22:41:46.008167+0200 DragTest[24732:2097487] [General] (
0 CoreFoundation 0x00007fff386292fd __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff64460720 objc_exception_throw + 48
2 CoreFoundation 0x00007fff38550f5b +[NSException raise:format:] + 201
3 AppKit 0x00007fff35e06033 -[NSDraggingSession(NSInternal) _initWithPasteboard:image:offset:source:] + 247
4 AppKit 0x00007fff35e05a4b -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1919
5 AppKit 0x00007fff35e052bd -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 134
6 AppKit 0x00007fff361ee12f -[NSOutlineView dragImage:at:offset:event:pasteboard:source:slideBack:] + 214
7 AppKit 0x00007fff362f6491 -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 656
8 AppKit 0x00007fff362f6925 -[NSTableView __doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 276
9 AppKit 0x00007fff362f76ba -[NSTableView _performClassicDragOfIndexes:hitRow:event:] + 466
10 AppKit 0x00007fff35e3d890 -[NSTableView _performDragFromMouseDown:] + 474
11 AppKit 0x00007fff35e3bb95 -[NSTableView mouseDown:] + 798
12 AppKit 0x00007fff35e3b660 -[NSOutlineView mouseDown:] + 73
13 AppKit 0x00007fff35b3bb3b -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5668
14 AppKit 0x00007fff35b09f9f -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2319
15 AppKit 0x00007fff35b094f1 -[NSWindow(NSEventRouting) sendEvent:] + 481
16 AppKit 0x00007fff35aab284 -[NSApplication(NSEvent) sendEvent:] + 336
17 AppKit 0x00007fff35bb44dd -[NSApplication run] + 755
18 AppKit 0x00007fff35b847e7 NSApplicationMain + 780
19 DragTest 0x000000010000387d main + 13
20 libdyld.dylib 0x00007fff6552d091 start + 1
)
This issue is present in the delegates of NSOutlineView, NSCollectionView and even in NSBrowser
When only one object is written it works as expected. Any idea how to avoid this?