-3

I have a folder, I like to be opened by NSWorkspace. But if access rights are missing, the entire app is crashing. How can I aviod this and show a message, that access rights were missing? I tried "try-catch", but this function does not throw errors!

NSWorkspace.shared.open(urlOutput)   // this could crash 
Peter71
  • 2,180
  • 4
  • 20
  • 33

1 Answers1

1

You can use isReadableFile method in FileManager.

if FileManager.isReadableFile(atPath: urlOutput.path) {
     NSWorkspace.shared.open(urlOutput)
    
} else {
     //Show an Error Message
}
udi
  • 3,672
  • 2
  • 12
  • 33