其實這個問題好久以前就遇過了,也解過,但總是會忘記。
備份一下以免以後再發生同樣問題。
這個問題其實就是在 App 中有下載檔案的話要,每一個檔案都要備註是否要 Backup 至  iCloud。
解法也很簡單,把整個 Document 全部設定成 Do NOT Backup 就好了。
解法原帖:http://stackoverflow.com/questions/19964831/ios-flag-entire-document-directory-as-do-not-backup
簡單來說就是在你的  AppDelegate.m 的 didFinishLaunch 裡面加上
NSString *docsDir;
NSArray *dirPaths;
NSURL * finalURL;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
finalURL = [NSURL fileURLWithPath:docsDir];
[self addSkipBackupAttributeToItemAtURL:finalURL];
skip backup 如下
- (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;
} 
沒有留言:
張貼留言