Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 905
Lee Avatar asked Sep 12 '25 05:09

Lee


1 Answers

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.

like image 179
Hayden Avatar answered Sep 13 '25 20:09

Hayden