IOS your app stores 18.79MB on the user's iCloud 应用被拒问题,

    亲测自己查阅资料解决,其实也不怎么难= =,好了,直接说解决思路。很简单,直接让iCloud 忽略 document的目录 不备份就可以了。没错,思路就是这么简单。

下面是苹果官方的方法 https://developer.apple.com/library/prerelease/content/qa/qa1719/_index.html

下面是我自己的代码:

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
      //解决2.1.1被拒问题,忽略document文件放置iCloud备份
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    if (paths.count > 0) {
        NSLog(@"NSDocumentDirectory paths = %@",paths[0]);
    [self addSkipBackupAttributeToItemAtPath:paths[0]];
    }
    
	return YES;
}
/**
 *  跳过iCloud 存储
 *
 *  @param filePathString app的url
 *
 *  @return
 */
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString
{
    NSLog(@"%s",__func__);
    NSURL* URL= [NSURL fileURLWithPath: filePathString];
    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;
}

第二段代码是苹果官方的, NSURLIsExcludedFromBackupKey  or  kCFURLIsExcludedFromBackupKey  这两个文件系统属性把文件从备份文件中排除。

我忽略的是document 的路径,相应的总结一下其他 文件的路径 = =,可忽略 

//1,获取家目录路径的函数:
NSString *homeDir = NSHomeDirectory();
//2,获取Documents目录路径的方法:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
//3,获取Caches目录路径的方法:
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDir = [paths2 objectAtIndex:0];
//4,获取tmp目录路径的方法:
NSString *tmpDir = NSTemporaryDirectory();
//5,获取应用程序程序包中资源文件路径的方法:
//例如获取程序包中一个图片资源(apple.png)路径的方法:
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"apple" ofType:@"png"];
UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
//代码中的mainBundle类方法用于返回一个代表应用程序包的对象。

下面是参考的博客 :

http://blog.csdn.net/wm9028/article/details/50293139

http://blog.csdn.net/shanglanxin/article/details/50395583

http://www.cnblogs.com/lzlsky/p/3333139.html

前人栽树后人乘凉,饮水思源。对自己负责,对他人负责。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值