将文件拖放到Cocoa中的Dock图标上 [英] Dropping Files onto Dock Icon in Cocoa
问题描述
如何将Info.plist中指定的类型的文件(或者选择在Finder中打开)放到我的停靠图标上,然后调用具有文件完整路径的方法?
How can I drop a file(or select to open it in Finder) of a type specified in the Info.plist onto my dock icon and then calling a method with the full path of the file?
推荐答案
如果您设置了Info.plist的 CFBundleDocumentTypes 数组正确(LSItemContentTypes或CFBundleTypeExtensions),然后您只需要设置一个NSApplication委托并实现委托方法, application:openFile:。
If you've set up your Info.plist's CFBundleDocumentTypes array properly (either 'LSItemContentTypes' or 'CFBundleTypeExtensions'), then you just need to set up an NSApplication delegate and implement the delegate method, application:openFile:.
如果你期待多个文件立即删除,实现 application:openFiles:。
If you're expecting multiple files to be dropped at once, implement application:openFiles:.
对于承诺文件( NSFilesPromisePboardType
/ kPasteboardTypeFileURLPromise
)请参阅将承诺文件删除到Dock中的应用程序图标< a>。
For promised files (NSFilesPromisePboardType
/kPasteboardTypeFileURLPromise
) see Dropping promised files on to application icon in Dock.
这篇关于将文件拖放到Cocoa中的Dock图标上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!