2012-03-29 30 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

相關問題