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

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

问题描述

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

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

我有一个Cocoa应用程序在10.6上运行,新的10.6 NSPasteboard 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天全站免登陆