security-scoped-bookmarks

MacOS sandboxed application: access files without NSOpenPanel

夙愿已清 提交于 2020-05-14 04:02:30
问题 In a sandboxed NSDocument-based application, any compatible document can be accessed using the NSOpenPanel, no matter where the document is saved. Without NSOpenPanel, the application can only access files in the sandbox container. As my application manages two types of subclassed NSdocument (Text as a reader/writer and Image as a reader only), I try to implement a separate "Open Recent" menu for images. I disabled the the ordinary behaviour for them as they are opened by the user, overriding

What is the correct way to handle stale NSURL bookmarks?

一世执手 提交于 2020-01-22 05:39:29
问题 When resolving an NSURL from a security scoped bookmark, if the user has renamed or moved that file or folder, the bookmark will be stale. Apple's document says this regarding staleness: isStale On return, if YES, the bookmark data is stale. Your app should create a new bookmark using the returned URL and use it in place of any stored copies of the existing bookmark. Unfortunately, this rarely works for me. It may work 5% of the time. Attempting to create a new bookmark using the returned URL

What are the current kernel resource limits on security-scoped bookmarks?

前提是你 提交于 2020-01-01 03:29:31
问题 The docs for -[NSURL startAccessingSecurityScopedResource] state: You must balance every call to the startAccessingSecurityScopedResource method with a corresponding call to the stopAccessingSecurityScopedResource method. If you fail to relinquish your access when you no longer need a file-system resource, your app leaks kernel resources. If sufficient kernel resources are leaked, your app loses its ability to add file-system locations to its sandbox, such as via Powerbox or security-scoped

Security Scoped Bookmark - bookmark resolves but still can't access the file

萝らか妹 提交于 2019-12-23 03:52:08
问题 EDIT: Additional information added at the bottom I have a sandboxed, document based application that loads a user selected quicktime movie into an AVPlayer, and everything was working perfectly. Now I am upgrading the code so that it will use Security Scoped bookmarks to get the URL rather than just storing a URL string so that the persistent store will allow the movie to be loaded upon relaunch of the application. When the bookmark is created it is stored in a Data variable of a managed

Security Scoped Bookmark - bookmark resolves but still can't access the file

给你一囗甜甜゛ 提交于 2019-12-06 17:34:25
EDIT: Additional information added at the bottom I have a sandboxed, document based application that loads a user selected quicktime movie into an AVPlayer, and everything was working perfectly. Now I am upgrading the code so that it will use Security Scoped bookmarks to get the URL rather than just storing a URL string so that the persistent store will allow the movie to be loaded upon relaunch of the application. When the bookmark is created it is stored in a Data variable of a managed object. For some reason, this has broken the AVPlayer. While I have created a bookmark from the user

What is the correct way to handle stale NSURL bookmarks?

让人想犯罪 __ 提交于 2019-12-02 22:12:49
When resolving an NSURL from a security scoped bookmark, if the user has renamed or moved that file or folder, the bookmark will be stale. Apple's document says this regarding staleness: isStale On return, if YES, the bookmark data is stale. Your app should create a new bookmark using the returned URL and use it in place of any stored copies of the existing bookmark. Unfortunately, this rarely works for me. It may work 5% of the time. Attempting to create a new bookmark using the returned URL results in an error, code 256, and looking in Console reveals a message from sandboxd saying deny file