Uninstall Open Recent in Cocoa Apps

I found a bunch of people who asked about this (delete or disable the submenu of the last items) and there are no answers.

After a little research ... the problem is that Apple secretly hard-coded that a particular menu always appears - even if you delete it, NSWindowController will quietly re-create it.

+3
source share
1 answer

EDIT: some idiot felt he was rewriting his answer. Not. Or I will remove it. According to a reviewer who initially declined to edit: "This change is too small, the proposed changes should be significant improvements, addressing several issues in the message." So: do not.


Apple has a formal decision (where they are reluctant to accept their mistake in hardcoding the menu):

http://developer.apple.com/library/mac/#qa/qa2001/qa1289.html

It seems that you are working fine once you install IBOutlet:

@property( nonatomic, retain) IBOutlet NSMenu* fileMenu;

... , AppDelegate, MainWindow.xib(, blue-cube Object AppDelegate)... NIB app-delegate.

EDIT: , - Apple Xcode4, . :

NSInteger openDocumentMenuItemIndex = [self.fileMenu indexOfItemWithTarget:nil andAction:@selector(openDocument:)];

if (openDocumentMenuItemIndex>=0 &&
    [[self.fileMenu itemAtIndex:openDocumentMenuItemIndex+1] hasSubmenu])
{
    // APPLE COMMENT: We'll presume it the Open Recent menu item, because this is
    // APPLE COMMENT: the heuristic that NSDocumentController uses to add it to the
    // APPLE COMMENT: File menu
    [self.fileMenu removeItemAtIndex:openDocumentMenuItemIndex+1];
}
+5

All Articles