-1

I have settings in my app which can limit PDF size that can be downloaded for app.

When PDF size that have been downloaded exceed that size, some PDF will be deleted.

I download the PDF and store it to documents folder.

Then, my app is rejected because don't follow this guideline. As far as I know, I can still download the PDF files to documents folder but can have them to be skipped to be backuped to iCloud by using NSURLIsExcludedFromBackupKey .

So my question is, is it ok to have NSURLIsExcludedFromBackupKey when storing the PDF and thus, it will not be rejected by Apple again?

Rendy
  • 5,572
  • 15
  • 52
  • 95
  • 1
    FYI your link doesn't work without an account. – lc. Feb 22 '13 at 06:23
  • 1
    Also, I think this question might be a bit off topic for SO? – lc. Feb 22 '13 at 06:24
  • Don't think so, because I've found this post http://stackoverflow.com/questions/11445308/apps-must-follow-the-ios-data-storage-guidelines-or-they-will-be-rejected , but the answer there suggests using cache and I don't want to use cache because it can be randomly deleted by system. – Rendy Feb 22 '13 at 06:28
  • Sorry for the link, I don't think Apple will be happy if I post the content of the link to here haha :D Sorry for that – Rendy Feb 22 '13 at 06:33
  • Your understanding is correct, and that document (as well as the linked [technical Q&A doc](https://developer.apple.com/library/ios/#qa/qa1719/_index.html)) sums it up quite nicely. What precisely is your question? – Rob Feb 22 '13 at 06:33
  • Hi Rob, thanks, i've edited my post. Sorry if it's not really clear, because I'm panic here :D – Rendy Feb 22 '13 at 06:38
  • @Rendy Yes, if you use `NSURLIsExcludedFromBackupKey` properly, you should back within compliance of the aforementioned guideline. – Rob Feb 22 '13 at 18:54

1 Answers1

1

I once had an app rejected for the same reason. After excluding downloaded files from being backed up it was approved. For setting that attribute I am using the following method:

// We do not want to backup this file to iCloud
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
    const char* filePath = [[URL path] fileSystemRepresentation];
    const char* attrName = "com.apple.MobileBackup";
    if (&NSURLIsExcludedFromBackupKey == nil) {
        // iOS 5.0.1 and lower
        u_int8_t attrValue = 1;
        int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
        return result == 0;
    } else {
        // First try and remove the extended attribute if it is present
        int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
        if (result != -1) {
            // The attribute exists, we need to remove it
            int removeResult = removexattr(filePath, attrName, 0);
            if (removeResult == 0) {
                NSLog(@"Removed extended attribute on file %@", URL);
            }
        }

        // Set the new key
        return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
    }
}

You mentioned that using a cache was no option because you do not have control over if the files will remain in cache or not. You could solve that by using a custom cache. If you want to see a sample for that, then have a look at: https://github.com/evermeer/EVURLCache

Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58