在另一个应用程序中打开文件时,在UIDocumentInteractionController中更改文件名

时间:2022-07-14 19:38:15

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.

例如我有一个名为abc.png文件,该文件存储在沙箱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

当我使用UIDocumentInteractionController在另一个应用程序中打开此文件时,我想让另一个文件打开文件名为abc.png的文件

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

目前,另一个应用程序将文件打开为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.

我已经尝试在documentInteractionControllerWillPresentOptionsMenu以及willBeginSendingToApplication中更改UIDocumentInteractionController的name属性,但是在这两种情况下接收应用程序都没有获得正确的文件名 - 它会继续显示模糊文件名。

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?

除了使用未混淆的名称创建文件的副本之外,有没有办法让接收应用程序使用所需的文件名?

1 个解决方案

#1


6  

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.

这将创建文件的硬链接。符号链接不起作用。

#1


6  

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.

这将创建文件的硬链接。符号链接不起作用。