NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0)
{
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *NineveshDict=[NSString stringWithFormat:@"%@/YourDir/",documentsDirectory];
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:NineveshDict isDirectory:YES]];
}
-(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
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 { // iOS >= 5.1
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
}