Thanks for the reply.
What I see in Xcode is not quite what you are describing, (no .xib files) but I think I am on the right track. So I have a few questions to get me a point to start playing with this more.
First, when I created the project, Xcode configured it with an AppDelegate class and a file named Main.storyboard as well as a ViewController. I added a few classes to implement my project model.
.
The storyboard includes an Application Scene, Window Controller Scene, and View Controller Scene.
As you can see the Menu Bar is in the Application Scene. So at this point I am not using a .xib file (though perhaps I am and just don't realize it). There is also an AppDelegate in the Application Scene.
So I have added the code you mentioned to the AppDelegate (didn't create a new one). This includes IBOutlets for the menu bar, file menu, and file open menu item and I connected them to the items in the StoryBoard.
And at this point I start becoming confused. So do I need to create an IBOutlet for the AppDelegate in the AppDelegate Class?? Also which menu item am I connecting to the newDossier function and how do I perform this connection? Do I simply use the items like menuBar, in this function?
Also I did run the code as implemented and the Open menu item was greyed out. Suspect I needed to do something to activate it.
//
// AppDelegate.swift
// BrackettedPhotoFinder
//
// Created by Develop on 5/25/19.
// Copyright © 2019 Develop. All rights reserved.
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: outlets for menus
@IBOutlet weak fileprivate var menuBar: NSMenu!
// File Menu
@IBOutlet weak fileprivate var fileMenu: NSMenu! // structure of menu
@IBOutlet weak var openDocumentMenuItem: NSMenuItem! // used by AppDelegate
//@IBOutlet weak fileprivate var fileMenu : NSMenu!
//@IBOutlet weak fileprivate var fileMenuItem : NSMenuItem! // item of menuBar
//@IBOutlet weak var newDocumentMenuItem : NSMenuItem! // used by AppDelegate
//@IBOutlet weak var openDocumentMenuItem : NSMenuItem!
//@IBOutlet weak fileprivate var saveDocumentAsMenuItem : NSMenuItem!
// Original functions in this class
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
// MARK: My functions to tie into menus
/* This code comes from a response to a question I submitted on the forums
* and answered by Claude31.
*/
@IBAction func newDossier(_ sender: NSMenuItem) {
// NSPanel stuff
print("In newDossier")
}
}
Thanks again for your insights,
Chip