在我的应用程序启动时,它会将我的资源文件夹中的一个库复制到 iOS 设备上的文档目录中。这是第一次启动时的一次性过程,再也没有碰过。Apple 今天拒绝了我的应用程序,原因如下:
我们发现您的应用未遵循 iOS 数据存储指南,这不符合 App Store 审核指南。
iOS 数据存储指南指出,只有用户使用您的应用程序创建的内容,例如文档、新文件、编辑等,才应由 iCloud 备份。
您的应用程序使用的临时文件应仅存储在 /tmp 目录中;请记住在用户退出应用程序时删除存储在此位置的文件。
可以重新创建但必须保留以使您的应用程序正常运行的数据 - 或者因为客户希望它可以离线使用 - 应该使用“不备份”属性进行标记。对于
NSURL
对象,添加NSURLIsExcludedFromBackupKey
属性以防止相应的文件被备份。对于CFURLRef
对象,使用相应的kCFURLIsExcludedFromBackupKey
属性。
我不确定如何设置不备份属性或者它是否是我需要的。谁能告诉我这是如何根据我的代码完成的?
-(void) progress
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = ([documentPaths count] > 0) ? [documentPaths objectAtIndex:0] : nil;
NSString *dataPath = [documentPath stringByAppendingPathComponent:pathWeSet];
if (![fileManager fileExistsAtPath:dataPath]) {
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *dataPath = [bundlePath stringByAppendingPathComponent:pathWeSet];
timer = [NSTimer timerWithTimeInterval:0.4 target:self selector:@selector(updateProgressView) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[timer fire];
if (dataPath) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[fileManager copyItemAtPath:dataPath toPath:dataPath error:nil];
});
}
}
}
谢谢