2014-01-16 63 views
0

我的iOS應用程序剛剛被拒絕,因爲應用程序在Documents上存儲數據,因此它由iCloud備份,因爲數據是從服務器下載的,所以這是不允許的。 但是,即使我使用addSkipBackupAttributeToItemAtURL它仍然顯示爲一個備份iCloud.Here我所使用的代碼addSkipBackupAttributeToItemAtURL不適用於iOS7

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方法

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

當我嘗試上述code.Still iCloud會在iOS7中顯示應用程序。請幫我解決這個問題。

+0

我不知道,但該文檔說*「一些常用的操作對用戶文件做出導致該財產被重置爲假.. 「*,所以這是我要檢查的第一件事。 –

回答

相關問題