如何在Mac OS X 10.5中处理Finder中的多个文件拖放? [英] How do I handle multiple file drag/drop from Finder in Mac OS X 10.5?

查看:291
本文介绍了如何在Mac OS X 10.5中处理Finder中的多个文件拖放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将所有文件的URL从Finder拖放到我的应用程序中。

I need to get the URLs of all files dragged/dropped into my application from Finder.

我有一个在10.6上运行的Cocoa应用程序,通过使用新的10.6 NAPasteboard API,可处理粘贴板上的多个项目。我试图将这个应用程序运送到10.5。如何处理这个10.5?

I have a Cocoa app running on 10.6 which does this by using the new 10.6 NSPasteboard APIs which handle multiple items on the pasteboard. I'm trying to backport this app to 10.5. How do I handle this on 10.5?

如果我做下面的事情,我只得到第一个URL:

If I do something like below, I only get the first URL:

    NSArray *pasteTypes = [NSArray arrayWithObjects: NSURLPboardType, nil];
    NSString *bestType = [pboard availableTypeFromArray:pasteTypes]; 
    if (bestType != nil) {
        NSURL *url = [NSURL URLFromPasteboard:pboard];
    }        


推荐答案

IKImageKit编程主题概述一个这样做的方式(释义):

The IKImageKit programming topics outline a way to do this like so (paraphrased):

   NSData *data = [pasteboard dataForType:NSFilenamesPboardType];
   NSArray *filenames = [NSPropertyListSerialization
        propertyListFromData:data
            mutabilityOption:kCFPropertyListImmutable
                      format:nil
            errorDescription:&errorDescription];

请参阅这里:图像套件编程指南:支持拖放

这篇关于如何在Mac OS X 10.5中处理Finder中的多个文件拖放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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