I am new to Mac OS programming. I have an Swift app I would like to create and the user will need to select a group of files/folders. I have done this using to select files that I can use in the app. I have managed to do this using a NSOpenPanel and modal window. I would prefer to do this using the File menu. I have found the Application Scene in Main.Storyboard but I have been unable to find any resources that desvcribe how I can connect code to the menu and then use it to open the folders/files as the openPanel does.
Frankly most of the searching I have done turns up iOS content which does me no good, so I am questioning my ability to even frame my questions properly for search engines.
Can anyone point me to decent resource(s) ?
Thanks,
Chip
In this case, I was not using storyboard (I do not use storyboards for MacOS apps), hence I had to recreate several things manually.
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?
In fact, the IBOutlet were created to allow for changing the menu item. May not need to start with, but if you want to disable…
With storyboard, no need to create the appDelegate; they are here and connected as needed.
So, you can create a new function,
- select the menu item (File>New) in storyboard
- open connections (connection isnpector or right clock)
- disconnect the IBAction (click on the small x in front of newDocument)
- control drag from the menuItem (in stroryboard) to the appDemegate to create the new action
- this is where you will have the code
This will replace the NSApp.newDocument() func