简体   繁体   中英

Change file name in UIDocumentInteractionController when opening file in another app

I'm storing files in my application sandbox in a way that masks the original name of the file.

For example I have a file called abc.png which is stored in the sandbox as obfuscated.png.

When I do an open in of this file in another application using a UIDocumentInteractionController I'd like to have the other file open the file with the filename abc.png

Currently the other app opens the file as obfuscated.png.

I have tried changing the name property of the UIDocumentInteractionController in documentInteractionControllerWillPresentOptionsMenu as well as willBeginSendingToApplication , however in both cases the receiving application does not get the correct filename - it continues to show the obfuscated filename.

Apart from creating a copy of the file with the unobfuscated name, is there a way to make the receiving application use the desired filename?

Instead of a copy try:

NSError *error = nil;
[[NSFileManager defaultManager] linkItemAtPath:obfuscatedFilePath toPath:abcFilePath error:&error];

This will create a hard link to the file. Symbolic links will not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM