In my app i have to store Core Data Database and audio files, so i decoded to put them in Documents directory. To prevent them from backing up, when i first launch the app, i put the Don't BackUp flag like this
在我的app中,我需要存储Core Data数据库和音频文件,所以我将它们解码到Documents目录中。为了防止他们备份,当我第一次启动应用程序时,我将Don't BackUp标记如下所示
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self addSkipBackupAttributeToItemAtURL:[self applicationDocumentsDirectory]];
}
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
- (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];
}
}
But it seems like it doesn't work - i still get rejected:
但这似乎不起作用——我仍然被拒绝:
We found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.
我们发现您的应用不遵循iOS数据存储指南,这是app Store评审指南要求的。
In particular, we found that on launch and/or content download, your app stores 3.6 MB. To check how much data your app is storing:
特别地,我们发现在发布和/或内容下载时,你的应用会存储3.6 MB的数据。
- Install and launch your app
- 安装并启动应用程序
- Go to Settings > iCloud > Storage & Backup > Manage Storage
- 到设置> iCloud >存储和备份>管理存储。
- If necessary, tap "Show all apps"
- 如有必要,点击“显示所有应用”
- Check your app's storage
- 检查你的应用程序的存储
And the other problem is that i just can't check that - i don't see my app in
另一个问题是我无法检查这个,我看不到我的应用
Settings > iCloud > Storage & Backup > Manage Storage
设置> iCloud >存储和备份>管理存储
Maybe the problem is only with 5.0 that i kind of not think about here?
也许问题只是我在这里没有考虑到的0。5 ?
1 个解决方案
#1
9
The problem is with iOS 5.0, in this iOS you should not put the dont backup flag The dont back up flag was introduced in ios 5.0.1 We did face similar problem with our app, it has been rejected several times So we had to do a work around to handle different iOSes We needed to support iOS < 5.0, iOS 5.0, and iOS > 5.0
iOS iOS 5.0的问题是,在这个你不应该把不备份国旗不备份国旗是在iOS 5.0.1引入我们面临类似问题应用,多次拒绝了所以我们必须做一个工作来处理不同的iOS我们需要支持iOS 5.0 < 5.0,iOS 5.0,和iOS >
So after contacting apple, we didnt find any solution except to have different paths on different iOSes
所以在联系苹果之后,我们没有找到任何解决方案,除了在不同的iOSes上有不同的路径
We had a function like this:
我们有一个这样的函数:
+ (NSString*) savePath
{
NSString *os5 = @"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4
{
return path;
}
else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above
{
return path;
}
else // IOS 5
{
path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
return path;
}
return nil;
}
We used and still use this function.
我们一直在使用这个函数。
Please read more
请阅读更多
iOS 5.0
iOS 5.0
It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.
在iOS 5.0上不可能从备份中排除数据。如果您的应用程序必须支持iOS 5.0,那么您需要将应用程序数据存储到缓存中,以避免备份数据。iOS会在需要的时候从缓存目录中删除你的文件,所以如果你的应用程序的数据文件被删除了,你需要优雅地降级。
http://developer.apple.com/library/ios/#qa/qa1719/_index.html
http://developer.apple.com/library/ios/ qa / qa1719 / _index.html
#1
9
The problem is with iOS 5.0, in this iOS you should not put the dont backup flag The dont back up flag was introduced in ios 5.0.1 We did face similar problem with our app, it has been rejected several times So we had to do a work around to handle different iOSes We needed to support iOS < 5.0, iOS 5.0, and iOS > 5.0
iOS iOS 5.0的问题是,在这个你不应该把不备份国旗不备份国旗是在iOS 5.0.1引入我们面临类似问题应用,多次拒绝了所以我们必须做一个工作来处理不同的iOS我们需要支持iOS 5.0 < 5.0,iOS 5.0,和iOS >
So after contacting apple, we didnt find any solution except to have different paths on different iOSes
所以在联系苹果之后,我们没有找到任何解决方案,除了在不同的iOSes上有不同的路径
We had a function like this:
我们有一个这样的函数:
+ (NSString*) savePath
{
NSString *os5 = @"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4
{
return path;
}
else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above
{
return path;
}
else // IOS 5
{
path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
return path;
}
return nil;
}
We used and still use this function.
我们一直在使用这个函数。
Please read more
请阅读更多
iOS 5.0
iOS 5.0
It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.
在iOS 5.0上不可能从备份中排除数据。如果您的应用程序必须支持iOS 5.0,那么您需要将应用程序数据存储到缓存中,以避免备份数据。iOS会在需要的时候从缓存目录中删除你的文件,所以如果你的应用程序的数据文件被删除了,你需要优雅地降级。
http://developer.apple.com/library/ios/#qa/qa1719/_index.html
http://developer.apple.com/library/ios/ qa / qa1719 / _index.html