如何隐藏在ios中的文档目录中创建的文件夹? [英] How to hide folders created in Document Directory in ios?
问题描述
我已经以编程方式创建了一些PDF文件,我使用以下代码将其存储到设备内存中>>>>
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];
我可以在Devices Document文件夹中看到该文件。
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.
推荐答案
存储私人数据的好地方是〜/ Library / Application Support /
,这是Mac上用于此目的的文件夹。
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:
NSString *appSupportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject];
你必须在第一次使用时自己创建文件夹,你可以用它来做:
You'll have to create the folder yourself the first time you use it, which you can do with:
if (![[NSFileManager defaultManager] fileExistsAtPath:appSupportDir])
{
[[NSFileManager defaultManager] createDirectoryAtPath:appSupportDir withIntermediateDirectories:YES attributes:nil error:NULL];
}
我写了一个简单的库,使这个和所有其他有用的iOS文件夹可用NSFileManager上的方法: https://github.com/nicklockwood/StandardPaths
I wrote a simple library that makes this and all other useful iOS folders available as methods on NSFileManager: https://github.com/nicklockwood/StandardPaths
这篇关于如何隐藏在ios中的文档目录中创建的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!