Im creating a NSWindowController and its window programatically. So i create a simple NSToolbar with:
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"PreferencesToolbar"];
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[toolbar setAllowsUserCustomization:NO];
[toolbar setAutosavesConfiguration:NO];
[self.window setToolbar:toolbar];
[toolbar release];
Which all works fine, but when I add
[toolbar setDelegate:self];
I get the following error:
ERROR: invalid delegate (does not implement all required methods), and so can not be used! (To debug, add a breakpoint to NSToolbarError
According to NSToolbarDelegate there are no required methods, so what is going wrong here?
In order to make the toolbar work with your
NSWindowControllersubclass as its delegate, you must declare it to conform toNSToolbarDelegateprotocol :Also, from the doc, you must ensure that some are implemented, even if they are optional, because you created the toolbar programmatically. They are :