应用必须遵循iOS数据存储指南,否则将在包含.pdf的应用中拒绝

时间:2014-03-10 05:28:54

标签: ios objective-c

我创建了一个电子书和ePaper应用程序,我的应用程序包含大量图像和pdf文件,我正在下载图像,pdf文件文档目录

图像目录:

           NSString *strPageURL = [dictPage valueForKey:@"imagelink"];
            strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@"\n" withString:@""];
            strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@"\t" withString:@""];
            strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@" " withString:@""];

            NSString* strFileName = [strPageURL lastPathComponent];
            NSString *strDestFile = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@",strFileName]];

Pdf目录

          NSString *strThumbURL = [dictPage valueForKey:@"thumbimage"];
            //  NSLog(@"%@",strThumbURL);
            NSString* strThumbName = [strThumbURL lastPathComponent];
            NSString *strThumbPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@",strThumbName]];

            BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:strThumbPath];

如何阻止文件备份到iCloud和iTunes?

-------------------------- 如何在我的代码中实现此方法 ------ -----------------------------

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                              forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
    NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}

1 个答案:

答案 0 :(得分:1)

是的,如果您下载大数据并将其存储在Documents目录中,您的应用可能会被拒绝。 我遇到过这个问题。

在此处阅读更多内容iOS 5 does not allow to store downloaded data in Documents directory?

Adding the "Do Not Backup" attribute to a folder hierarchy in iOS 5.0.1