title: Prevent Data backup with iCloud and itunes
body: <p>I am developing an iOS application. the user can download books, the size of books ar > 200 Mo. To respect the apple storage guidelines, we are doing like this :</p>
  
  <pre><code> + (NSString *)booksStoragePath
      {
  
          NSArray *path = [NSArray array];
          NSString *os5 = @"5.0";
          NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  
          if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above
          {        
              path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
  
          }
          else // IOS 5
          {
              path = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
          }
  
         NSString *documentsDirectory = [path objectAtIndex:0]; // Get documents directory
          NSString *storagePath = [documentsDirectory stringByAppendingPathComponent:@"Books"];
  
          if (![[NSFileManager defaultManager] fileExistsAtPath:storagePath])
              [[NSFileManager defaultManager] createDirectoryAtPath:storagePath withIntermediateDirectories:YES attributes:nil error:nil];
  
  NSUrl *url = [NSUrl urlWithString:storagePath];
  [self addSkipBackupAttributeToItemAtURL:url];
  
          return storagePath;
      }
  </code></pre>
  
  <p>And to not backup the "Books" directory, i am doing like this :</p>
  
  <pre><code>#pragma mark --
  #pragma mark Data Backup
  - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
  {
      NSString *os5 = @"5.0.1";
      NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  
  
      if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedSame) //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, &amp;attrValue, sizeof(attrValue), 0, 0);
          return result == 0;
  
      }
      else{
          if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) {
  
  
  
              NSError *error = nil;
              BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                            forKey: NSURLIsExcludedFromBackupKey error: &amp;error];
              if(!success){
                  NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
              }
              return success;
          }
      }
  
      return nil;
  
  }
  </code></pre>
  
  <p>The problem is i am seeing the folder "Books" in iTunes connect an i can download it, and all the content of the books are there !!!!!</p>
  
  <p>How i can forbid that the directory "Books" and it's content does not synchronize with iCloud ans does not appear in the iTunes ?</p>
  
  <p>Thanks for your answers.</p>