• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing security scoped URLs from multiple threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing security scoped URLs from multiple threads


  • Subject: Re: Accessing security scoped URLs from multiple threads
  • From: Charles Srstka <email@hidden>
  • Date: Wed, 19 Mar 2014 20:50:45 -0500

On Mar 19, 2014, at 7:29 PM, patrick machielse <email@hidden> wrote:

> We are working on a sandboxed application that keeps track of a large number of files through security scoped URLs. To access the files we carfully balance our calls to startAccessingSecurityScopedResource / stopAccessingSecurityScopedResource:
>
> [url startAccessingSecurityScopedResource]
> /* do some work */
> [url stopAccessingSecurityScopedResource]
>
>
> All was fine until we needed to start accessing the files from multiple threads simultaneously. 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.
>
> It seems that we must design our own bookkeeping around security scoped urls, make sure we don't manage resource access directly in our frameworks, and hope no 3rd party frameworks call stopAccessingSecurityScopedResource behind our backs. We find this API design disappointing (to say the least), it's as if we need to call retain / release *and also* manage the retain count ourselves...
>
>
> Sandboxing is a good idea in theory, but the implementation has been kicking sand (.) in our faces for a while now.
>
> Did we miss some hidden feature? Did anyone design a re-usable solution for accessing security scoped resources from multiple threads?
>
> We'd be grateful for any ideas!
>
> patrick

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.

Charles


_______________________________________________

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


  • Follow-Ups:
    • Re: Accessing security scoped URLs from multiple threads [SOLVED]
      • From: patrick machielse <email@hidden>
    • Re: Accessing security scoped URLs from multiple threads
      • From: Mike Abdullah <email@hidden>
References: 
 >Accessing security scoped URLs from multiple threads (From: patrick machielse <email@hidden>)

  • Prev by Date: Accessing security scoped URLs from multiple threads
  • Next by Date: Re: Accessing security scoped URLs from multiple threads
  • Previous by thread: Accessing security scoped URLs from multiple threads
  • Next by thread: Re: Accessing security scoped URLs from multiple threads
  • Index(es):
    • Date
    • Thread