In addition, my project now targets iOS 5.0. From what I understand in 5.0, there is no way to prevent a possible clearing of the cache folder. Should I only support> = 5.0.1?
There is no way to do this in 5.0, so you should keep everything in a place that can be cleaned up by the OS, such as NSCachesDirectory . I believe that it is best to deal with all cases 5.0, 5.0.1 and 5.1; use NSCachesDirectory for 5.0 and NSApplicationSupportDirectory for 5.0.1 and 5.1. This is a mess, but as you noted, Apple quickly added a new attribute in 5.0.1 and improved the experience in 5.1.
we had rejected applications because we did not handle all the different cases, YMMV.
However, when I test the application with the device, there is still about 28kb sent to iCloud (and nothing in the / documents folder is a sandbox for application applications, according to the Organizer). My project does not support iCloud, so I do not understand what is sent when there is nothing in the documents.
This applies if the user backs up their device in iCloud, and not if you use iCloud in your application. I would not worry about the extra 28 KB, I also saw this in our applications, I think that this is probably the overhead of third-party libraries, such as analytics packages or other items that store small amounts of data in these places. As indicated, NSUserDefaults can also be stored here. You can download data from the Xcode organizer and see what is stored if you're interested.
Here is a way to handle the backup attribute not in 5.0.1 and 5.1.
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL { if (&NSURLIsExcludedFromBackupKey == NULL) { // Use iOS 5.0.1 mechanism 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; } else { // Use NSURLIsExcludedFromBackupKey mechanism, iOS 5.1+ NSError *error = nil; BOOL success = [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error]; //Check your error and take appropriate action return success; } }