This is bothering me because its too simple… Ok I have this code in MyDocument.h
-(void)new:(id)sender { [NSApp newDocument]; }
And I get this error during runtime…
Can anyone point out any mistakes?
I’m trying to have an NSToolbarItem that creates a new document.
add a selector to your toolbar’s target and hook up your toolbar item to it.
-(IBAction)createNewDocument:(id)sender {[[NSDocumentController sharedDocumentController] newDocument:nil];} ---- How would I initiate a save?
Even better than ceating a -createNewDocument: method, set the toolbar item’s action to @selector(newDocument:) and target to nil (first responder). To initiate a save, do the same, except change the action. You can find out the appropriate actions by opening up the MainMenu in IB and using the inspector to check the actions. That’s what makes Cocoa great: the responder chain means that you don’t have to create these sort of redundant methods.