由于朋友遇到appstore上架問(wèn)題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
這是由于把大量的數(shù)據(jù)存放在documents下的問(wèn)題认然,appStore 的iCloud備份這里面的數(shù)據(jù)
解決方法1:就是不讓iCoud備份數(shù)據(jù)妓布,跳過(guò)ICloud的備份
蘋(píng)果的解決辦法的地址: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的路徑的方法(其實(shí)就是你文件的路徑):
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
}
解決方法二:就是不讓打的重用的數(shù)據(jù)放到Documents文件夾下
1堡掏、圖片的緩存可以放到/tmp文件夾下會(huì)
2、下載可以重用的東西放/Library/Caches