将文件拖放到 Cocoa 中的 Dock 图标上 [英] Dropping Files onto Dock Icon in Cocoa

查看:20
本文介绍了将文件拖放到 Cocoa 中的 Dock 图标上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 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委托并实现委托方法,应用程序: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 中的应用程序图标上.

For promised files (NSFilesPromisePboardType/kPasteboardTypeFileURLPromise) see Dropping promised files on to application icon in Dock.

这篇关于将文件拖放到 Cocoa 中的 Dock 图标上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆