如何隐藏在ios文档目录中创建的文件夹?
我以编程方式创建了一些 PDF 文件,我使用以下代码将其存储到设备内存中>>>>>
NSString *fileName = [NSString stringWithFormat:@"SampleTextFile.pdf",strFinalString];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *saveDirectory = [path objectAtIndex:0];
NSString *saveFileName = fileName;
NSString *documentPath = [saveDirectory stringByAppendingPathComponent:saveFileName];
我可以在设备文档文件夹中看到该文件。
我想隐藏这些文件,以便用户无法看到或删除它。
任何人都可以帮我做到这一点。
I have created some PDF files programatically, which i am storing into the devices memory using the following code >>>>
NSString *fileName = [NSString stringWithFormat:@"SampleTextFile.pdf",strFinalString];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *saveDirectory = [path objectAtIndex:0];
NSString *saveFileName = fileName;
NSString *documentPath = [saveDirectory stringByAppendingPathComponent:saveFileName];
I can see the file in the Devices Document folder.
I want to hide these files so that the user can not see or delete it.
Can anyone help me out to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
存储私人数据的好地方是
~/Library/Application Support/
,这是 Mac 上用于此目的的文件夹。您可以使用以下方法生成此文件夹的路径:
您必须在第一次使用它时自己创建该文件夹,您可以这样做:
我编写了一个简单的库,使该文件夹和所有其他有用的 iOS 文件夹可作为方法使用NSFileManager: https://github.com/nicklockwood/StandardPaths
A good place to store private data is in
~/Library/Application Support/
, which is the folder used on the Mac for this purpose.You can generate a path to this folder using:
You'll have to create the folder yourself the first time you use it, which you can do with:
I wrote a simple library that makes this and all other useful iOS folders available as methods on NSFileManager: https://github.com/nicklockwood/StandardPaths
只需在文件名前面加上一个点,如
.SampleTextFile.pdf
中所示。但真正的解决方案是首先不将文档存储在 NSDocumentDirectory 中。您应该在
NSLibraryDirectory
中创建子目录并将这些内容存储在那里。它还会得到备份,不会像Caches
和tmp
那样被清除,但用户无法使用 iTunes 访问它。Just prefix the filename with a dot, as in
.SampleTextFile.pdf
.But the real solution is to not store the document in the
NSDocumentDirectory
in the first place. You should create subdirectory in theNSLibraryDirectory
and store this stuff there. It also gets backed up and will not get purged likeCaches
andtmp
, but the user cannot access it with iTunes.