IOS Storage Failure

My application was rejected because it should follow iOS storage guidelines. I already read some answer here on stackoverflow and I already read some blogs ... I know my problem, when I first run the application, I copy 1 sqlite db and unzip some images in the document folder. The problem is that it automatically backs up any files in the document directory. I do not need to use icloud in my application, but my files should remain in the documents folder, because they are the basic data of my application and must be persit (cache folder or temporary folder are wrong decisions). So I read about the flag, that I can install the file by file to prevent backups:

[URL setResourceValue: [NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: nil];

I also read that this method only works in ios above 5.0.1, in another it will simply be ignored (I set the goal of ios deployment in 4.3) ... If I use this method, my application will be rejected again, because more old ios backup devices not managed? If so, is there a cross-iosversion method to set NSURLIsExcludedFromBackupKey?

EDIT I'm sorry that icloud is missing in ios earlier than 5.0, so I believe that the problem only concerns the differences between version 5.0 and 5.0.1, am I mistaken?

+5
source share
4 answers

I transferred all the files to be saved in the document folder using this method.

try it

-(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
    NSError *error = nil;
    [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
    return error == nil;
}
}

Stack Overflow:

+3

:

NSString *mediaDir = [NSString stringWithFormat:@"%@/Library/Caches/%@", NSHomeDirectory(), MEDIA_DIRECTORY];

. , :

NSArray* lCachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString* lCacheDirectory = [lCachePaths objectAtIndex:0];
+3

, ( ) , , , , /.

, , .

sqlite: , sqlite.

+1

Caches/. , . ( ), .

NSString *mediaDir = [NSString stringWithFormat:@"%@/Library/Caches/%@", NSHomeDirectory(), MEDIA_DIRECTORY];

. , , , , Temp, - .

+1

All Articles