【问题标题】:why my app is rejected from appstore although i am not using icloud为什么我的应用程序被应用商店拒绝,虽然我没有使用 icloud
【发布时间】:2014-12-03 23:59:04
【问题描述】:

我没有使用任何 icloud 存储

原因 2.23:应用程序必须遵循 iOS 数据存储指南,否则将被拒绝 ----- 2.23 -----我们发现您的应用没有遵循 iOS 数据存储指南,这是 App Store 审核指南所要求的。特别是,我们发现在启动和/或内容下载时,您的应用程序存储 21.12 MB。要检查您的应用程序存储了多少数据:- 安装并启动您的应用程序- 转到设置> iCloud > Storage & Backup > Manage Storage - 如有必要,请点击“显示所有应用程序” - 检查您的应用程序的存储空间iOS 数据存储指南表明只有用户的内容使用您的应用程序创建的文件,例如文档、新文件、编辑等,应由 iCloud 备份。您的应用程序使用的临时文件应仅存储在 /tmp 目录中;请记住在用户退出应用程序时删除存储在此位置的文件。可以重新创建但必须保留以使您的应用程序正常运行的数据 - 或者因为客户希望它可以离线使用 - 应该使用“不备份”属性进行标记。对于 NSURL 对象,添加NSURLIsExcludedFromBackupKey 属性以防止相应文件被备份。对于 CFURLRef 对象,使用相应的kCFURLIsExcludedFromBackupKey 属性。有关更多信息,请参阅技术问答 1719:如何防止文件备份到 iCloud 和 iTunes?。

将数据离线存储到 Sqlite 我的功能是

+ (NSString*)saveImageInDocuments:(UIImage*)senderImage {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSDate *selected = [NSDate date];

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"ddmmyyyyhhmmss"];
    NSString *imgName = [dateFormat stringFromDate:selected];

    imgName = [NSString stringWithFormat:@"%@.jpg",imgName];

    NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:imgName];

    UIImage *image = senderImage;
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
    [imageData writeToFile:savedImagePath atomically:YES];
     NSLog(@"path is... %@",savedImagePath);
    return imgName;



}

为了从 sqlite 离线获取数据,我正在使用此功能

+ (UIImage*)getImageFromDocuments:(NSString*)senderImageName {

    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:senderImageName];

    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL fileExist = [fileManager fileExistsAtPath:getImagePath]; // Returns a BOOL

    UIImage *img = [[UIImage alloc] init];
    if(fileExist)
    {
        img = [[UIImage alloc] init];
        img = [UIImage imageWithContentsOfFile:getImagePath];
    }
    NSLog(@"path is... %@",getImagePath);
    return img;
}

【问题讨论】:

标签: ios iphone sqlite app-store


【解决方案1】:

您必须为不想在 iCloud 上同步的文件设置标志。默认情况下 iOS 同步。如果设备设置允许,iCloud 上的应用数据。

使用此方法从备份中跳过文件

- (BOOL)addSkipBackupAttributeToItemAtURL: (NSURL *)URL {

    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version > 5.0) {
        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;
    }
    return NO;
}
[self addSkipBackupAttributeToItemAtURL:[[NSURL alloc] initFileURLWithPath:"YOURFILEPATH"]];

【讨论】:

  • 我应该在哪里使用这个功能?
  • 在appDidFinishLaunching方法中调用
  • NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; [self addSkipBackupAttributeToItemAtURL:[[NSURL alloc] initFileURLWithPath:documentsDirectory]];
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多