1

I am trying to unmount a mounted volume in case it meets certain conditions and for that I am using the following code.

FileManager.default.unmountVolume(at: URL(fileURLWithPath: convictedFile), options: [FileManager.UnmountOptions.allPartitionsAndEjectDisk, FileManager.UnmountOptions.withoutUI], completionHandler: {(_) in})

When I use this code, it force unmounts the volume. I do not want to unmount it in case the user is still working on any of the files present inside it. Is there any way to check whether the user has any files of the mounted volume open? Thanks.

SaudiSheep
  • 35
  • 6
  • 4
    Have you tested this yourself, the call has a completion handler with an Error as a parameter so maybe it generates an error if you have a file open? – Joakim Danielson Jun 03 '21 at 06:08
  • I am fairly new to the language and I dont know how to use the completion handler for that purpose. I have tested having files open and it force umounts the volume. Can you tell me how to use the completion handler? – SaudiSheep Jun 03 '21 at 06:19

0 Answers0