I try to add a service to my application. This application has a service called, let's say, "MyService". I have a file in the Finder and I would like to copy that file with a new name at the same location. The user would right-click on the file and select MyService. A new file would appear with a new filename next to the original one. The problem is that my application is sandboxed. I can get the url of the file selected with :
- (NSPasteboardItem*)merge:(NSPasteboard *)pboard
userData:(NSString *)userData error:(NSString **)error {
NSArray* fileArray=[pboard propertyListForType:NSFilenamesPboardType];
}
My fileArray would contain the filepath. I can then change this filepath with the new filename. If I just create a new file using :
NSString *filePath = [filesArray objectAtIndex:0];
PDFDocument *PDF = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:filePath]];
NSURL *newFileUrl =[NSURL fileURLWithPath:newfilepath];
[PDF writeToURL:newFileURL];
I get an error! I know what I am doing is wrong but how to tell the Finder that the User did commit the action and so this action is secured in a way. How to tell this newFileURL is allowed? Thank you for your help