Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
439 views
in Technique[技术] by (71.8m points)

ios4 - How to hide folders created in Document Directory in ios?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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];
}

I wrote a simple library that makes this and all other useful iOS folders available as methods on NSFileManager: https://github.com/nicklockwood/StandardPaths


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...