How to hide folders created in Document Directory in ios?

后端 未结 2 1908
暖寄归人
暖寄归人 2020-12-18 01:19

I have created some PDF files programatically, which i am storing into the devices memory using the following code >>>>

    NSString *fileName = [NSString s         


        
2条回答
  •  渐次进展
    2020-12-18 01:48

    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

提交回复
热议问题