2012-05-28 2 views
4

최근 iOS 앱은 애플리케이션이 문서에 데이터를 저장하여 iCloud에 의해 백업되기 때문에 방금 거부되었습니다. 데이터는 서버에서 다운로드되기 때문에 허용되지 않습니다.addSkipBackupAttributeToItemAtURL이 구현 된 경우에도 여전히 iCloud에 백업됩니까?

지금 코드를 다시 작성하려고하는데 폴더에 데이터를 저장할 때 응용 프로그램 지원을 대신 호출해야합니다.

비록 addSkipBackupAttributeToItemAtURL을 사용하고 있지만 여전히 iCloud에 백업으로 표시됩니다.

5.1 만 대상으로하므로 버전 문제는 아닙니다.

NSString *newPath = [NSMutableString stringWithFormat:@"%@/Library/Application Support/", NSHomeDirectory()]; 

    if (![[NSFileManager defaultManager] fileExistsAtPath:newPath]) //Does directory already exist? 
    { 
     if (![[NSFileManager defaultManager] createDirectoryAtPath:newPath 
             withIntermediateDirectories:NO 
                 attributes:nil 
                  error:&error]) 
     { 
      NSLog(@"Create directory error: %@", error); 
     } 

    } 

    NSString *guidesPath = [newPath stringByAppendingPathComponent:@"/Guides"]; 
    if (![[NSFileManager defaultManager] fileExistsAtPath:guidesPath]) //Does directory already exist? 
    { 
     if (![[NSFileManager defaultManager] createDirectoryAtPath:guidesPath 
             withIntermediateDirectories:NO 
                 attributes:nil 
                  error:&error]) 
     { 
      NSLog(@"Create directory error: %@", error); 
     } 

    } 

    NSString *dataPath = [guidesPath stringByAppendingPathComponent:dbName]; 

    if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) 
    { 
     if (![[NSFileManager defaultManager] createDirectoryAtPath:dataPath 
             withIntermediateDirectories:NO 
                 attributes:nil 
                  error:&error]) 
     { 
      NSLog(@"Create directory error: %@", error); 
     } 

    } 

    NSString *newGuidesPath = [dataPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    NSURL *guidesURL = [NSURL URLWithString:newGuidesPath]; 
    [self addSkipBackupAttributeToItemAtURL:guidesURL]; 

    NSString* path = [dataPath stringByAppendingPathComponent: 
         [NSString stringWithString: finalName] ]; 
    if (![fileManager fileExistsAtPath:path]) { 
     [myData writeToFile:path atomically:YES]; 
     NSString *docFile = [dataPath stringByAppendingPathComponent: @"guideid.txt"]; 
     [[guideID dataUsingEncoding:NSUTF8StringEncoding] writeToFile:docFile atomically:NO]; 
     DLog(@"Saved database here:%@", path); 
    }else{ 
     DLog(@"Already exists, no need to copy"); 
    } 

} 

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

답변

9

사실 해결책을 찾았습니다. 필요하지 않은 URL을 인코딩했습니다. 그냥 바로 작동하는 것 같다 코드, 내부를 플래그, 폴더

NSURL *guidesURL = [NSURL fileURLWithPath:guidesPath]; 
    [guidesURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:NULL]; 

이 추가 그리고이 방법을 제외 건너 뜁니다.

0

당신이 아이 클라우드 설정에서 백업 장치에 새로운 만들 시도해 봤어 :

나는 아래 여기에 영향을받는 코드를 추가 한?

+0

이것은 실제로 내 문제를 해결했습니다. – user3687

관련 문제