• 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: Failure to create bookmarkData in sandboxed app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Failure to create bookmarkData in sandboxed app


  • Subject: Re: Failure to create bookmarkData in sandboxed app
  • From: Antonio Nunes <email@hidden>
  • Date: Sat, 11 May 2013 15:51:14 +0100

On 11 May, 2013, at 09:50 , Markus Spoettl <email@hidden> wrote:

>> NSError *error = nil; NSURLBookmarkCreationOptions options =
>> NSURLBookmarkCreationSuitableForBookmarkFile |
>> NSURLBookmarkCreationWithSecurityScope; NSData *bookmarkData = [self.url
>> bookmarkDataWithOptions:options includingResourceValuesForKeys:nil
>> relativeToURL:nil error:&error];
>
> Have you tried using just NSURLBookmarkCreationWithSecurityScope as options?

When I do that, the bookmarkData gets created. I then found that after loading the data back in when running the app again, then if I wanted to use the URL, [userBookmark.url startAccessingSecurityScopedResource] returned NO. However, it turns out that I was not reading the data back in properly. I had written this:

    self.url = [NSURL URLByResolvingBookmarkData:urlData
                                                   options:NSURLBookmarkResolutionWithoutUI
                                             relativeToURL:nil
                                       bookmarkDataIsStale:&bookmarkIsStale
                                                     error:&error];

Turns out had overlooked that another option needs to be passed in:

    self.url = [NSURL URLByResolvingBookmarkData:urlData
                                                   options:NSURLBookmarkResolutionWithoutUI | NSURLBookmarkResolutionWithSecurityScope
                                             relativeToURL:nil
                                       bookmarkDataIsStale:&bookmarkIsStale
                                                     error:&error];

Duh.

So, it looks like it is working. Except: now, if the file is moved from where it was when the bookmark data was created, it is no longer found. When passing in NSURLBookmarkCreationSuitableForBookmarkFile as an option in the non sandboxed version this does retain access to the file when the file is moved. Neither do the documents suggest that NSURLBookmarkCreationSuitableForBookmarkFile and NSURLBookmarkCreationWithSecurityScope are mutually exclusive options. The question then remains, are they mutually exclusive? —Thus making bookmarks in sandboxed apps considerably less flexible than in non-sandboxed apps.) Or should this be possible but something else is preventing this from working?

- António


_______________________________________________

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


References: 
 >Failure to create bookmarkData in sandboxed app (From: Antonio Nunes <email@hidden>)
 >Re: Failure to create bookmarkData in sandboxed app (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: NSWorkspace launchApplicationAtURL:options:configuration:error cannot launch a app
  • Next by Date: Accounts framework - does unexpected things sometimes / freezes system preferences ...
  • Previous by thread: Re: Failure to create bookmarkData in sandboxed app
  • Next by thread: Accounts framework - does unexpected things sometimes / freezes system preferences ...
  • Index(es):
    • Date
    • Thread