I have a non-document-based application in which I would like to use the "Open Recent" menu item to open a recently opened item. I've implemented this using application:openFile:
and noteNewRecentDocumentURL:
as described here.
AppDelegate.m (excerpt)
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
[self.someController openRecentDocument:filename];
return YES;
}
SomeController.m (excerpt)
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:filePath]];
This seems to partially work initially, with the document appearing in the menu after calling noteNewRecentDocumentURL:
but after relaunching the app, the "Open Recent" menu is empty.
Is there something else I need to do to get this to work properly?