在使用此代码从iCloud备份中排除文件后,为什么我的应用程序仍然被拒绝? [英] Why was my application still rejected after excluding files from iCloud backup using this code?

查看:180
本文介绍了在使用此代码从iCloud备份中排除文件后,为什么我的应用程序仍然被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了以下代码以从iCloud备份中排除文件,但我的应用程序仍被拒绝:

I have added the following code to exclude files from iCloud backup, but my application was still rejected:

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


        NSLog(@"%d",[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil]);
        return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
    }
}

我将以下网址作为NSURL传递,在模拟器的情况下:

and I passed the below url in as an NSURL, in the case of the Simulator:


file:///Users/TEST/Library/Application%20Support/iPhone%20Simulator/5.1/ Applications / 62854BAB-AB51-4771-895F-28C61983A7AC / Documents / MyFolder

file:///Users/TEST/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/62854BAB-AB51-4771-895F-28C61983A7AC/Documents/MyFolder"

任何人都可以建议我的错误在哪里?

Can any one suggest where my mistake is in this?

推荐答案

问题在于您传入的网址。

The problem is with the URL your passing in.

即使您将数据存储在文件夹中,该数据仍然是两件事

Even though you are storing your data in a Folder, that Data is still two things


  1. 在文档文件夹中,它将是同步

  2. 文件夹与您的应用程序相关联

要解决此问题,您需要将其存储在/中库而不是/ Documents

To solve this you need to store it in /Library instead of /Documents

所以你的URL将是


file:/ //Users/TEST/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/62854BAB-AB51-4771-895F-2 8C61983A7AC / / MyFolder

file:///Users/TEST/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/62854BAB-AB51-4771-895F-28C61983A7AC/Library/MyFolder

在Library文件夹中存储不可同步的数据或任何外部数据是自iCloud实施以来苹果新的偏好

Storing non sync-able data or just any external data in the Library folder is Apples new preference since iCloud was implemented

这篇关于在使用此代码从iCloud备份中排除文件后,为什么我的应用程序仍然被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆