2012-03-29 102 views
1

我有一种方法来读取/查询OSX上的桌面细节。我想获取像文件的文件&文件夹可见的桌面上有那里的位置?获取桌面上存在位置的图标和文件的详细信息?

我想我可以使用NSFileManger中的以下api,它可以给文件和文件夹。

- (NSArray *)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(NSArray *)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error 

但我还需要桌面文件的位置和那里对应的图标。任何人都可以帮助我或提出一些想法吗?

回答

-1

对于图标,你可以使用

[NSWorkspace sharedWorkspace] iconForFile:filePath]; 

你可以使用AppleScript为桌面项目的立场。

tell application "Finder" to ¬ 
    get the name of every item of desktop 
tell application "Finder" to ¬ 
    get the position of every item of the desktop 
+0

可以在没有脚本的情况下完成吗? – MacGeek 2012-04-05 14:44:37