if fileURL.startAccessingSecurityScopedResource() { // put your code here } fileURL.stopAccessingSecurityScopedResource()