Ok, now I'm thououghly ticked off. What started as a simple utility project (using the above code) has now turned into a nightmare, due to sandboxing. While I might be able to live with manually setting the output using an (inconvenient) Save Panel, we also desired to make this an automatic option, not requiring the user to do anything to make it happen. Noooooo way, Jose! Looks like we are going to have to, at the very least, deal with coordinated writing (a PITA). I don't understnd any of this stuff, but have figured out that the documented File Access Temporary Exceptions are totally useless unless you always want to write to one location.
I did find "OSX App Sandboxing & Related Items tutorial" which is written in outdated Swift which I will have to translate into Objective C. If I can figure out exactly what it is doing, I might be able to use that. However, it appears that you have to add document types that the app really cant open, and besides, our conversion utility is a singleton at the application level.
This is all utterly ridiculous. There has to be a better way. If the PowerBox can figure out it's ok to access a particular location, why can't we just give it a URL and let it figure out if it's ok? Huh? Huh? Get with it out there in the new Space Port, how about it!
Later:
I tried doing this using related items with a file coordinator. So far, no luck.
- (void) convertWithCoordinator {
self.fileData = [FileData fileDataWithPath:self.srcPath];
[NSFileCoordinator removeFilePresenter:self.fileData];
[NSFileCoordinator addFilePresenter:self.fileData];
FileData *fData = self.fileData;
NSURL *url = fData.presentedItemURL;
NSError *error;
__block BOOL failure = YES;
NSFileCoordinator *coord = [[NSFileCoordinator alloc] initWithFilePresenter:fData];
[coord coordinateWritingItemAtURL:url options:0 error:&error byAccessor:^(NSURL *newURL){
[self convertMOVToMP4AtURL:newURL];
failure = NO;
}];
if(failure || error != nil)
NSLog(@"%@", error.description);
}
fileData conforms to NSFilePresenter. Requisite info is included in info.plist. No failure occurs here. convertMOVToMP4AtURL is the same as used when the SavePanel is used (successfully). Running it gets "cannot create file". Obviously, "newURL" is NOT the security scoped URL that I need. Why not?