我使用下面的文件目录创建文件夹,我的问题是,如何隐藏这个文件夹,这样当我允许itune共享此文件夹时不会出现给用户
/ *创建新目录* / NSFileManager * filemgr; NSArray * dirPaths; NSString * docsDir; NSString * newDir;
filemgr =[NSFileManager defaultManager];
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
newDir = [docsDir stringByAppendingPathComponent:@"Patients"];
NSLog(newDir);
if(! [self SearchForDirectory:newDir] )
{
NSLog(@"directory Not Exists");
if ([filemgr createDirectoryAtPath:newDir withIntermediateDirectories:YES attributes:nil error: NULL] == NO)
{
NSLog(@"Failed to create directory");
}
}
else{
NSLog(@"directory Exists");
}
[filemgr release];
答案 0 :(得分:6)
您可以通过在文件夹名称前加上一个点(。)来隐藏iTunes文件共享中的文件夹。因此路径Documents/MyHiddenFolder
将被称为Documents/.MyHiddenFolder
但是,现在建议将私有数据文件存储在Library
目录中,或存储在其子目录中。有关详细信息,请参阅以下Apple Q&A。
答案 1 :(得分:1)
Documents目录用于用户的文档。如果您正试图从那里隐藏文件,那么它们可能不是文档,您应该将文件存储在one of the other directories中。我们在谈论什么文件?
请注意,在该目录中包含启用iTunes文件共享的非文档是App Store拒绝的理由。