---
title: stopAccessingSecurityScopedResource()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nsurl/stopaccessingsecurityscopedresource()
---

# stopAccessingSecurityScopedResource()

In an app that adopts App Sandbox, revokes access to the resource pointed to by a security-scoped URL.

## Declaration

```swift
func stopAccessingSecurityScopedResource()
```

## Discussion

Discussion When you no longer need access to a file or directory pointed to by a security-scoped URL, such as one returned by resolving a security-scoped bookmark, call this method on the URL to relinquish access. You can also use its Core Foundation equivalent, the CFURLStopAccessingSecurityScopedResource(_:) function. 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. warning: If you fail to relinquish your access to file-system resources when you no longer need them, your app leaks kernel resources. If sufficient kernel resources leak, your app loses its ability to add file-system locations to its sandbox, such as with Powerbox or security-scoped bookmarks, until relaunched. If you call this method on a URL whose referenced resource you don’t have access to, nothing happens. note: Security-scoped bookmarks aren’t available in versions of macOS prior to OS X 10.7.3.

## See Also

### Working with Bookmark Data

- [bookmarkData(withContentsOf:)](foundation/nsurl/bookmarkdata(withcontentsof:).md)
- [bookmarkData(options:includingResourceValuesForKeys:relativeTo:)](foundation/nsurl/bookmarkdata(options:includingresourcevaluesforkeys:relativeto:).md)
- [resourceValues(forKeys:fromBookmarkData:)](foundation/nsurl/resourcevalues(forkeys:frombookmarkdata:).md)
- [writeBookmarkData(_:to:options:)](foundation/nsurl/writebookmarkdata(_:to:options:).md)
- [startAccessingSecurityScopedResource()](foundation/nsurl/startaccessingsecurityscopedresource().md)
- [NSURL.BookmarkFileCreationOptions](foundation/nsurl/bookmarkfilecreationoptions.md)
- [NSURL.BookmarkCreationOptions](foundation/nsurl/bookmarkcreationoptions.md)
- [NSURL.BookmarkResolutionOptions](foundation/nsurl/bookmarkresolutionoptions.md)
