Re: Accessing security scoped URLs from multiple threads [SOLVED]
Re: Accessing security scoped URLs from multiple threads [SOLVED]
- Subject: Re: Accessing security scoped URLs from multiple threads [SOLVED]
- From: patrick machielse <email@hidden>
- Date: Thu, 20 Mar 2014 15:53:33 +0100
Op 20 mrt. 2014, om 02:50 heeft Charles Srstka <email@hidden> het volgende geschreven:
> On Mar 19, 2014, at 7:29 PM, patrick machielse <email@hidden> wrote:
>
>> According to the documentation:
>>
>> "When you call the stopAccessingSecurityScopedResource method, you immediately lose access to the resource in question (even if you have previously called startAccessingSecurityScopedResource more than once)."
>>
>> Thus, as soon as 1 thread executes its 'stopAccessingSecurityScopedResource', all access in other threaded code blocks is lost.
>
> Have you tried using CFURLStartAccessingSecurityScopedResource instead of -startAccessingSecurityScopedResource? This is what the documentation has to say about it:
>
> "Calls to the CFURLStartAccessingSecurityScopedResource function (or its Cocoa equivalent) are nestable on a per-process basis. This means that if your app calls the start method on a URL twice, to fully relinquish access to the referenced resource you must call the corresponding stop method twice."
>
> Of course, it also claims that the Cocoa method does this, so who knows.
It seems that the description of CFURLStartAccessingSecurityScopedResource() is correct and also applies to -[NSURL startAccessingSecurityScopedResource]. I've reported this error to the documentation team.
It turned out that I wasn't resolving the bookmarks correctly from within the sandbox. This made the call to 'startAccessingSecurityScopedResource' fail, but because the powerbox already enables access to the resource this would not be problematic for the first user of the url. Only when that user stopped accessing the url, and the next user would try to use it, the problems would start.
Thanks for your input.
patrick
--
Patrick Machielse
Hieper Software
http://www.hieper.nl
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden