1

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?

DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
  • Did you use the stop button from Xcode ? I noticed that I have to close application properly to save the opened file entries in the menu. – David Mangon Sep 06 '15 at 08:33
  • I didn't use the stop button (I used Cmd-Q), but running the application as a normal executable outside of Xcode seems to have fixed the problem. If you'd like to put that as an answer I'll happily accept it. – DanielGibbs Sep 06 '15 at 08:53

0 Answers0