When and Where to Modify the Recents Meno

An easy question. The documentation for NSDocumentController has a section called Managing the Open Recents Menu. It's straight forward. What I don't get is where or where to call these methods. I need to remove some items from that menu.


Thanks

Accepted Reply

As explained here, you should send a notification each time you want to add to the list:

You have to send this message to the shared instance, whenever you want to add an item to the recent docs list:

[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:theURLOfTheDocYourAppOpens];

https://stackoverflow.com/questions/37558606/how-to-implement-show-recents-item-on-os-10-9-and-later


So I do the following:

- load the list of recent files when appDidFinisLaunching

- on the close file menu, I append to the menu (after checking it is not yet present)

- I have a menu option to clear the list.


Hope that helps.

Replies

As explained here, you should send a notification each time you want to add to the list:

You have to send this message to the shared instance, whenever you want to add an item to the recent docs list:

[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:theURLOfTheDocYourAppOpens];

https://stackoverflow.com/questions/37558606/how-to-implement-show-recents-item-on-os-10-9-and-later


So I do the following:

- load the list of recent files when appDidFinisLaunching

- on the close file menu, I append to the menu (after checking it is not yet present)

- I have a menu option to clear the list.


Hope that helps.

So, I can do it whenever it want to. I was trying to make the change when the Recents menu was triggered. Trying to do something simple the hard way again. Sigh!


Thanks