Search code examples
iosiphoneappstore-approval

App got rejected not following the iOS Data Storage Guidelines


My app has downloadable content which I am keeping in Documents Directory. Which gets backed up on iCloud. So instead of setting "Do not backup" of all individual files can I put them under one directory in side Documents and set the "Do not backup" on that directory will that work? or do I have to set the flag on all individual files.


Solution

  • Use below code in your application before saving database to your document directory..

    -(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
    {
        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);
    
    //  NSLog(@"Attributs : %d and Path : %@",result,URL);
        if (result != 0) { 
    
            NSLog(@"File Backup Attribute setting error");
    
        }
    
        return result == 0;
    }