如何实现从照片到我的 Cocoa 应用程序的完整质量拖放?

How do I implement drag-and-drop from Photos to my Cocoa app with full quality?

在我的拖动目标视图(NSView 子类)中,我实现了:

override func performDragOperation(_ draggingInfo: NSDraggingInfo) -> Bool {

    // check for Photos promises
    var gotPromised = false
    draggingInfo.enumerateDraggingItems(options: [], for: self, classes: [NSFilePromiseReceiver.self], searchOptions: [:], using: {(draggingItem, idx, stop) in
        let filePromiseReceiver = draggingItem.item
        print("got a file promise receiver: \(filePromiseReceiver)")
        gotPromised = true
        // Use filePromiseReceiver here for your task.
    })
    return gotPromised
}

当我 运行 从 Photos.app 中拖出一些东西时,我收到这个警告:

如何解决我的拖动目的地没有这个警告?我想在我的应用程序中获取高质量的照片。

嗯。经过一番调查,我自己弄明白了。您需要做很多事情(注册正确的类型,正确枚举项目等),如果您只是完全正确地实现承诺接收,则不会出现警告。 Apple 提供了一个 example project 可以正确实现所有内容。