I am trying to implement drag n drop. hit a spot where nothing works and the docs are unclear. In the context of trying to get a drop to work, I think I've run afoul one of the more annoying issues that crops up when writing swift and working wth cocoa... that is: Types are always wildly ambiguous.
So, with that in mind does anyone know what the pasteboardPropertyList for type function In the NSPasteboardWriting protocol expects to be returned?
func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any?
I had assumed a dictionary full of PropertyList compatible types.
maybe that's not my issue, But this is what the docs say:
The returned value will commonly be the
NSData
object for the specified data type. However, if this method returns either a string, or any other property-list type, the pasteboard will automatically convert these items to the correct data format required for the pasteboard.and as I understand it: a dictionary is one such object.
context:
I have an object that is not NSCoding compliant (yet) and it supports NSPasteboardWrietable and NSPasteboardReadable. it is primariliy composed of Strings and Floats.
I have run everything through the debugger a handful of times, and the drop triggers all of the expected methods.
the result is somewhat less than satisfactory tho.
if let nodes = pasteBoard.readObjects(forClasses: [docDataObj.self], options:nil) as? [docDataObj]{
appData?.docData += nodes
return true
}
this block of code is in the performDragOperation method of the NSDraggingDestination, and I always get an empty array.
I've also just tried:
let types = pasteBoard.types
if let dic = pasteBoard.propertyList(forType: NSPasteboard.PasteboardType(rawValue: "com.bktools.node")){
debugPrint("got something")
return true
}else{
return false
}
the types array, shows very clearly that the paseboard supports the "com.bktools.node" type. But I do not get a return value for the propertyList call. I thought that was going to be it because I am using a propertyList, and this should balance out the calls, but I'm still getting nothing.