要从 iTunes 文件共享中隐藏您的应用,您可以在 info.plist 中将以下密钥设置为 No。
应用程序支持 iTunes 文件共享
或者,在您的文件名/目录前面添加带有 . 的 Documents 目录以在不禁用 iTunes 文件共享的情况下隐藏它。例如。 .folderName.
使用它来防止 iCloud 备份,来自Prevent Backup to iCloud,is following code correct?
- (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 备份应用程序,请使用这个 sn-p
//************************************************************************
// 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