Is there a way to list the last used files using cocoa (or objective-c) functions?
I would like to h开发者_Go百科ave something like "recent documents"
Thanks for your help.
Regards,
Use -[NSDocumentController recentDocumentURLs]. It returns an array of URLs representing the locations of the documents recently opened by your application.
Edit based on comment: In that case, you need to use the Launch Services API. For example:
- (NSArray *)globalRecentDocumentsURLs {
    LSSharedFileListRef recentDocsFileList;
    NSArray *recentDocsFiles;
    NSMutableArray *recentDocsURLs = nil;
    UInt32 seed;
    recentDocsFileList = LSSharedFileListCreate(NULL,
        kLSSharedFileListRecentDocumentItems, NULL);
    if (! recentDocsFileList) return nil;
    recentDocsFiles = (NSArray *)LSSharedFileListCopySnapshot(recentDocsFileList,
        &seed);
    if (recentDocsFiles) {
        recentDocsURLs = [NSMutableArray array];
        for (id file in recentDocsFiles) {
            CFURLRef fileURL = NULL;
            LSSharedFileListItemResolve((LSSharedFileListItemRef)file, 0,
                &fileURL, NULL);
            if (fileURL) [recentDocsURLs addObject:[(id)fileURL autorelease]];
        }
        [recentDocsFiles release];
    }
    CFRelease(recentDocsFileList);
    return recentDocsURLs;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论