Home > Software engineering >  NSOpenPanel - exclude startup disk
NSOpenPanel - exclude startup disk

Time:10-10

Using NsOpenPanel, I would like to exclude the startup disk from the dialog (grey out). If not possible, I would like to get the path to the startup disk ("/Volumes/Macintosh HD" most of the time but not always) as an URL. I have not found anything related to startup disk and swift on the net. Could someone help me? Thanks.

CodePudding user response:

First of all the path to the startup disk is always /

To disable the URL in the panel adopt NSOpenSavePanelDelegate and implement

func panel(_ sender: Any,
           shouldEnable url: URL) -> Bool {
    return url.path != "/"
}
  • Related