我有一种方法可以读取/查询OSX上桌面的详细信息。我想获取在桌面上可见的文件和文件夹之类的信息?

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

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


但是我还需要桌面文件的位置,并有相应的图标。谁能帮我或提出一些想法?

最佳答案

对于图标,您可以使用

[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

关于objective-c - 获取桌面上存在的图标和文件的详细信息,并在桌面上找到位置?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9922683/

10-12 00:41
查看更多