由于朋友遇到appstore上架问题2.23 Details On launch and content download, your app stores 15.83MB on the user's iCloud, which does not comply with the iOS Data Storage被拒。
2.23 Details On launch and content download, your app stores 15.83MB on the user's iCloud, which does not comply with the iOS Data Storage
这是由于把大量的数据存放在documents下的问题,appStore 的iCloud备份这里面的数据
解决方法1:就是不让iCoud备份数据,跳过ICloud的备份
苹果的解决办法的地址:https://developer.apple.com/library/prerelease/content/qa/qa1719/_index.html
Object C代码:
ios5.1 later
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString
{
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;
}
使用方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self addSkipBackupAttributeToItemAtPath:@"<myApplication>/Library/Caches"];
return YES;
}
附录:获取url的路径的方法(其实就是你文件的路径):
NSArray * arrayOfURLs = [[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask];
// make certain there's at least one file url returned by the above call
if([arrayOfURLs count] > 0)
{
// and this would just be the URL to the cache directory...
NSURL * cacheDirectoryPath = [arrayOfURLs objectAtIndex: 0];
// ... to create a file url to your actual dictionary, you'd need to add a
// filename or path component.
// Assuming you save this as a property within your object
self.cacheFileURL = [cacheDirectoryPath URLByAppendingPathComponent: @"myDatabase.db"];
}
Swift代码:
func addSkipBackupAttributeToItemAtURL(filePath:String) -> Bool
{
let URL:NSURL = NSURL.fileURLWithPath(filePath)
assert(NSFileManager.defaultManager().fileExistsAtPath(filePath), "File \(filePath) does not exist")
var success: Bool
do {
try URL.setResourceValue(true, forKey:NSURLIsExcludedFromBackupKey)
success = true
} catch let error as NSError {
success = false
print("Error excluding \(URL.lastPathComponent) from backup \(error)");
}
return success
}
使用方法
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
addSkipBackupAttributeToItemAtURL("忽略的路径")
return true
}
解决方法二:就是不让打的重用的数据放到Documents文件夹下
1、图片的缓存可以放到/tmp文件夹下会
2、下载可以重用的东西放/Library/Caches