简体   繁体   English

addSkipBackupAttributeToItemAtURL不适用于iOS7

[英]addSkipBackupAttributeToItemAtURL not working with iOS7

My iOS application just got rejected because the application is storing data on Documents so it is backed up by iCloud, this is not allowed since the data is downloaded from a server. 我的iOS应用程序刚刚被拒绝,因为该应用程序将数据存储在文档中,因此由iCloud进行了备份,这是不允许的,因为数据是从服务器下载的。 But even though I'm using addSkipBackupAttributeToItemAtURL it still shows up as a backup to iCloud.Here the code which i have used 但是即使我正在使用addSkipBackupAttributeToItemAtURL,它仍然会显示为iCloud的备份。这是我使用的代码

    NSError *error = nil;
    NSData *data = [NSData dataWithContentsOfURL:url options:0 error:&error];
    if(!error)
    {
       [self HidePreLoader];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
         NSLog(@"_paths--->%@",paths);
        NSString *path = [paths objectAtIndex:0];
         NSLog(@"_path---->%@",path);
        NSString *dataPath = [path stringByAppendingPathComponent:@"/MyFolder"];
         NSLog(@"_dataPath---->%@",dataPath);
        if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
        {
            [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
        }
        NSString *zipPath = [dataPath stringByAppendingPathComponent:downfilename];
        [data writeToFile:zipPath options:0 error:&error];
        if(!error)
        {
            [self HidePreLoader];
            ZipArchive *za = [[ZipArchive alloc] init];
            if ([za UnzipOpenFile: zipPath]) {
                BOOL ret = [za UnzipFileTo: dataPath overWrite: YES];
                if (NO == ret){} [za UnzipCloseFile];
                 NSLog(@"folderPath--->%@",folderPath);
   //Here i have used the use code
                NSURL *guidesURL = [NSURL fileURLWithPath:folderPath];
                [guidesURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:NULL];
  //The following code also doesnt work
  //NSURL *guidesURL = [NSURL fileURLWithPath:folderPath];
  //[self addSkipBackupAttributeToItemAtURL:guidesURL];

                  [self HidePreLoader];
                NSString *path = nil;
                if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
                {
                    path = [folderPath stringByAppendingPathComponent:@"module-B1-ipadmain-swipe-tablet.html"];
                }
                else
                {
                    path = [folderPath stringByAppendingPathComponent:@"module-B1-ipadmain-swipe-phone.html"];
                }

                NSLog(@"path--->%@",path);

                dispatch_async(dispatch_get_main_queue(), ^{

                    appDel.currentReadingPlanWithPath = path;
                    appDel.moduleDownloaded = YES;
                    [appDel SetCurrentDownloadPath];
                    NSLog(@"file download success");
                    [progview setHidden:YES];
                    [progval setHidden:YES];
                    [self HidePreLoader];
                    downloadView.userInteractionEnabled=YES;
                    [self SetModuleDownloaded:@"true"];
                    [self ShowAlert:@"Download" message:@"Success"];
                     [self HidePreLoader];
                                    });
                 [self HidePreLoader];
            }
        }
        else
        {
            NSLog(@"Error saving file %@",error);
        }
    }
    else
    {
        NSLog(@"Error downloading zip file: %@", error);
    }

});

AddSkipBackupAttributeToItemAtURL method AddSkipBackupAttributeToItemAtURL方法

-(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;
}

When i try the above code.Still the iCloud shows the application in iOS7.Please help me to solve this issue. 当我尝试上述代码时.iCloud仍显示iOS7中的应用程序。请帮助我解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM