I'm reading a bit outdated book about Cocoa/Objective-C applications development and I'm trying to code some examples. And so I ended up with an almost empty NSDocument-based app with runtime errors like that: Internal inconsistency in menus - menu <NSMenu: 0xbc726d040> Title: Window Supermenu: 0xbc726d080 (Main Menu), autoenable: YES Previous menu: 0x0 (None) Next menu: 0x0 (None) Items: ( "<NSMenuItem: 0xbc6fcd9a0 Minimize, ke='Command-M'>", "<NSMenuItem: 0xbc6fcda40 Zoom, ke mask='<none>'>", "<NSMenuItem: 0xbc6fcdae0, separator, ke mask='<none>'>", "<NSMenuItem: 0xbc6fcd900 Bring All to Front, ke mask='<none>'>" ) believes it has <NSMenu: 0xbc726d080> Title: Main Menu Supermenu: 0x0 (None), autoenable: YES Previous menu: 0x0 (None) Next menu: 0x0 (None) Items: ( ) as a supermenu, but the supermenu does not seem to have any item with that submenu It looks like as if the menu tries to include itself as a submenu. Am I right? I have no ideas what led to this. If I'm not mistaken this has started since macOS Tahoe. The code that is not a boilerplate one I have:
// Document.m
#import "Document.h"
@implementation Document
@synthesize text;
- (NSString *)windowNibName {
return @"SampleDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
[super windowControllerDidLoadNib:aController];
if (self.text == nil) {
self.text = @"";
}
self.textField.stringValue = self.text;
}
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError {
self.text = self.textField.stringValue;
return [self.text dataUsingEncoding:NSUTF8StringEncoding];
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
if ([data length] > 0) {
NSString * string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
self.text = string;
}
else {
self.text = @"";
}
return YES;
}
+ (BOOL)autosavesInPlace {
return YES;
}
@end
There are two xib's: MainMenu.xib and Document.xib but I won't include them here. Please advise how to fix this menu issue.