問題描述
我以編程方式創(chuàng)建了一些 PDF 文件,我使用以下代碼將其存儲到設備內(nèi)存中 >>>>
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.
誰能幫我做這件事.
推薦答案
存儲私有數(shù)據(jù)的好地方是~/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];
您必須在第一次使用它時自己創(chuàng)建文件夾,您可以這樣做:
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 的文檔目錄中創(chuàng)建的文件夾?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!