How to use NSURLIsExcludedFromBackupKey Or kCFURLI

2019-05-10 18:27发布

问题:

My App had been rejected because I save in-app purchase data in Documents folder on iPhone.

Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute.

But I want the user to use the data even if they are offline, so I'll use kCFURLIsExcludedFromBackupKey or NSURLIsExcludedFromBackupKey. What is the different between them?

The question is how to use any of them, and what will it return and how can I use this returned data?

回答1:

NSError *error = nil;

BOOL result = [fileURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];