My SwiftUI macOS app is successfully using security scoped URLs like so below.
// Start accessing the security-scoped resource
if restoredURL.startAccessingSecurityScopedResource(){
print("startAccessingSecurityScopedResource: \(restoredURL)")
}
Apple's documentation states:
You must balance each call to startAccessingSecurityScopedResource() for a given security-scoped URL with a call to stopAccessingSecurityScopedResource(). When you make the last balanced call to stopAccessingSecurityScopedResource(), you immediately lose access to the resource in question.
My assumption would be that I need to call stopAccessingSecurityScopedResource when my app exits as my app might use all resources until it is terminated. Is this the best approach and if so, how can I call this on app closure?