You can just go ahead and invoke -noteNewRecentDocumentURL: on [NSDocumentController sharedDocumentController]. You don't have to worry about explicitly creating or managing an NSDocumentController, or do anything else that requires NSDocument.

TextEdit in Tiger did this (before it was converted to NSDocument).
Ali



On Jul 20, 2009, at 8:47 , Graham Cox wrote:


On 21/07/2009, at 1:36 AM, Alexander Bokovikov wrote:

Hi, All,

I'm writing a simple (in GUI) application, where NSDocument is not used. I use NSOpenPanel to get a file name, then process file and close it. There is no UI, related to file, where NSDocument could help significantly. At least I believe so.

My problem is that Recent menu is empty, because in Cocoa (AFAIK) it is maintained automatically by NSDocumentController, which is absent in my app. So, my question is - how to create and update the Open Recent menu "manually"? Where to store its items? How to populate this submenu when my app is loaded?

Or should I use NSDocumentController anyway?


If your app isn't document based, it might complicate things too much to have an NSDocumentController there (which is a global/ singleton).

Handling a recent items menu is pretty straightforward though - just keep a list of the <n> most recent file paths you opened in an array and use a menu delegate to update the menu from this. For extra credit, check the validity/existence of the file when updating the menu and remove bad ones and disambiguate duplicates. Someone might have written a class to do this already.

The relevant functionality could go in the app's delegate or a separate controller object with an outlet from the app's delegate.

--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to