我在NSDocumentDirectory中创建了私人文件夹,我想将其隐藏在iTunes中并不允许备份。
在此问题中,如何在ios中隐藏在“文档目录”中创建的文件夹?人们建议保存在私人目录中。
Application_Home / Library /您不应将此目录用于用户数据文件。
在iTunes11之前,此解决方案适用于我
但现在我在iTunes中看到包含私人文档的文件夹。
有人可以帮我吗?
要在iTunes文件共享中隐藏您的应用,可以No
在info.plist中将以下键设置为。
应用程序支持iTunes文件共享
或者,在您的文件名/目录之前添加在Documents目录中,并在其中添加文件.
以隐藏它而不禁用iTunes File Sharing。例如.folderName
。
使用此代码可防止iCloud备份(从“阻止备份到iCloud”)是否正确?以下代码是否正确?
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)filePathString {
NSURL *fileURL = [NSURL fileURLWithPath:filePathString];
assert([[NSFileManager defaultManager] fileExistsAtPath: [fileURL path]]);
NSError *error = nil;
BOOL success = [fileURL setResourceValue:[NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey
error: &error];
return success;
}
并且为了防止设备锁定时从XCode Organizer备份应用程序,请使用此代码段
//************************************************************************
// Method for making files and folders secure
//************************************************************************
+ (void)makeItemAtPathSecure:(NSString *)path
{
NSError *securingFilesError;
NSFileManager *manager=[NSFileManager defaultManager];
NSDictionary *attrs = [manager attributesOfItemAtPath:path error:&securingFilesError];
if(![[attrs objectForKey:NSFileProtectionKey] isEqual:NSFileProtectionComplete])
{
if(![manager setAttributes:[NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey] ofItemAtPath:path error:&securingFilesError])
{
NSLog(@"Problem in securing files: %@",[securingFilesError localizedDescription]);
}
}
else
{
NSLog(@"Problem in securing files: %@",[securingFilesError localizedDescription]);
}
}
要在iTunes中有选择地隐藏文件夹,请尝试使用来重命名该文件夹。在此之前,例如folderName应该是.folderName
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句