问题及尝试:
我在做一个跨平台文件拷贝的功能,文件可能是从其他操作系统比如Linux 或者Windows 拷贝到Macos上, 但是我试过所有可以hook NSPasteboard的方法,确实没有找到可以监听macos 剪切板的方法,因为fileURL 确实在NSPasteboard是一个类型的数据,这个数据的value 其实是一个路径,我们可以通过下载macos 里面的一个工具 Pasteboard Viewer: Pasteboard Viewer on the App Store
从工具中我们可以看到当我自macos 本地copy一个file时 会有fileURL的数据类型被加到NSPasteboard里面
从截图可以得知 fileURL数据类型的值其实就是一个路径,因此我们通过NSPasteboard 提供的回调方法
@protocol NSPasteboardItemDataProvider <NSObject>
/* Implemented by the data provider of a pasteboard item, to provide the data for a particular UTI type.
*/
@required
- (void)pasteboard:(nullable NSPasteboard *

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



