4

I don't want anything to be backed up to iCloud. However, my data cannot be recreated, so I need to place it in my application's documents directory. For each file, I did the standard:

    - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
        const char* filePath = [[URL path] fileSystemRepresentation];

        const char* attrName = "com.apple.MobileBackup";
        u_int8_t attrValue = 1;

        int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
        return result == 0;
    } else { // iOS >= 5.1
        return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
    }
}

I have 5mB of data in there. But my app is still registering 0.2kB in iCloud (Through settings->iCLoud->Manage Storage). So, just to be sure, I did this:

-(void)resetBackupAttributes {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSArray *fileListAct = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
    for (NSString *path in fileListAct) {
        [self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:path]];
    }

    NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *cacheDirectory = [paths2 objectAtIndex:0];
    NSArray *fileListCache = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:cacheDirectory error:nil];
    for (NSString *path in fileListCache) {
        [self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:path]];
    }
    NSArray *paths3 = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSUserDomainMask, YES);
    NSString *preferencesDirectory = [paths3 objectAtIndex:0];
    NSArray *fileListPref = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:preferencesDirectory error:nil];
    for (NSString *path in fileListPref) {
        [self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:path]];
    }
}

It still has 0.2kB! Is there something I am missing? Does a small amount of data gets backed up regardless... like a directory tree or something? What I really want to know is, will this 0.2kB get me rejected for not following the data storage guidelines?

4

1 に答える 1

0

わかりましたので、コメントを回答に入れます。

アプリのデフォルト plist がクラウドにバックアップされる可能性はありますか? - ただし、iOS (シミュレーター) とインターネットの間にプロキシを接続することはできます。すべての送信データをキャッチして、実際に何が送信されるかを確認してください;)。例: SquidMan

念のため、ここにSquidManへのリンクがあります …<br> あなたが言ったように、それも plist だと思います。いくつかのジャンク データを使用してキーを設定し、合計金額が上昇するかどうかを確認することで、これを確認できます。;)

于 2012-04-24T16:21:40.150 に答える