osx - QLPreviewView can not show the quicklook preview in sandbox -


i use qlpreviewview show quicklook preview in app. without sandbox, works well, once change app sandbox, preview can not show up.

i found error in console: quicklookuihelpe(20786) deny file-read-data xxx.

i have used security-scoped bookmarks & com.apple.security.files.user-selected.read-write grant access user home dir, then:

[allowedurl startaccessingsecurityscopedresource]; self.mypreiviewitem.myurl = fileurl; self.myqlpreviewview.previewitem = self.mypreiviewitem; [self.myqlpreviewview refreshpreviewitem]; [allowedurl stopaccessingsecurityscopedresource]; 

with these, can delete files of user home dir, qlpreviewview can not work. not know difference between these 2 scenes, qlpreviewview need more sandbox?

if add com.apple.security.files.downloads.read-only entitlement, files in "downloads" can previewed, other files of user home dir can not previewed.

finally have found solution!

refreshpreviewitem async call, before mac finishes loading preview, following api stopaccessingsecurityscopedresource shutdown access, result, mac failed load preview successfully.

so solution is: not call stopaccessingsecurityscopedresource here, keep allowedurl's access right until not need ql preview function, , call stopaccessingsecurityscopedresource there, such when closing window.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -