Re: document inexplicably becomes locked and fails to save under sandboxing
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