• 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: document inexplicably becomes locked and fails to save under sandboxing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: document inexplicably becomes locked and fails to save under sandboxing


  • Subject: Re: document inexplicably becomes locked and fails to save under sandboxing
  • From: Martin Wierschin <email@hidden>
  • Date: Wed, 11 Jun 2014 12:15:29 -0700

I need to do some more testing, but I may have a workaround for my problem. Instead of opening the document via NSDocumentController, ask NSWorkspace to open the file in my app instead:

{
	NSURL* resolvedURL = XXDocumentURLResolvedFromBookmarkData();
	[resolvedURL startAccessingSecurityScopedResource];

	NSString* appPath = [[NSBundle mainBundle] bundlePath];
	BOOL isOpened = [[NSWorkspace sharedWorkspace] openFile:[resolvedURL path] withApplication:appPath];

	[resolvedURL stopAccessingSecurityScopedResource];
}

I imagine NSWorkspaces triggers whatever OSX sandboxing magic is needed to keep file access intact for the lifetime of the document.

This workaround is pretty straightforward, though it's a little awkward when the client needs access to the actual NSDocument* afterwards. I'm going to have to override NSDocumentController's open methods and match up the file URL to completion handlers I've stashed away somewhere. Not a big deal, but a little ugly.

Best,
~Martin Wierschin


_______________________________________________

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: document inexplicably becomes locked and fails to save under sandboxing
      • From: Martin Wierschin <email@hidden>
References: 
 >document inexplicably becomes locked and fails to save under sandboxing (From: Martin Wierschin <email@hidden>)
 >Re: document inexplicably becomes locked and fails to save under sandboxing (From: SevenBits <email@hidden>)
 >Re: document inexplicably becomes locked and fails to save under sandboxing (From: Martin Wierschin <email@hidden>)

  • Prev by Date: Re: document inexplicably becomes locked and fails to save under sandboxing
  • Next by Date: Re: Another app's UTI can break your app
  • Previous by thread: Re: document inexplicably becomes locked and fails to save under sandboxing
  • Next by thread: Re: document inexplicably becomes locked and fails to save under sandboxing
  • Index(es):
    • Date
    • Thread