title: Can't write large file (> 200MB, 700MB in my case) in ios device?
body: <p>I am having the problem of writing large file (>200 MB) in iOS device (iPad) but in the simulator it works perfect.<br>
  I am using <code>NSFileManager</code> to create file and <code>NSFileData</code> to write file.
  I think there is no problem in my code as it runs fine in the simulator. 
  Does anyone having the same problem?</p>
  
  <p>To elaborate my situation:</p>
  
  <p>I am saving chunk of files (3MB each) in my device which works fine. That means for a 300 MB file I have 100 chunks. Now, from the 100 chunks I want to create the actual file. So I am using the <code>NSFileManager</code> to create file in first iteration and then using <code>NSFileData</code> to write the 3MB data at the end of the file. While running the program it crashes after 61 chunks. I am guessing there might have some memory related issues in the iPad.</p>
  
  <p>I am saving the chunk of files in <code>fileDir</code> in the format data-0, data-1, data-2...
  I am applying the decrypt operation on data but for simplicity I have removed that portion.</p>
  
  <pre><code>// List of chunk files        
  NSArray *filelist= [[NSFileManager defaultManager] contentsOfDirectoryAtPath:fileDir error:err];
  for(int i = 0; i &lt; [filelist count]; i++) {
                  // Read the chunk of file
                  fileName = [[NSString alloc] initWithFormat:@"data-%d", i];
                  filePath = [fileDir stringByAppendingPathComponent:fileName];
                  fileReadHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];
  
                  // Write in tempFile
                  if(offset == 0){
                      if([[NSFileManager defaultManager] createFileAtPath:tempFile contents:data attributes:nil]){
                          fileWriteHandle = [NSFileHandle fileHandleForWritingAtPath:tempFile];
                          NSLog(@"File was created!");
                      } else {
                          NSLog(@"File was not created.");
                      }
                  } else {
                     [fileWriteHandle seekToEndOfFile];  // Tried with comment out this line but same problem
  // Write the decrypted data from chunk
              [fileWriteHandle writeData:[[fileReadHandle readDataToEndOfFile] decryptedAES256DataUsingKey:AESEncryptionKey error:err]];
                      }
                  }
  </code></pre>
  
  <p><strong>Edit (11.02.2013)</strong>
  I tried with my previous code where I omitted the data decryption part.
  Interestingly, the problem was in the decryption part I guess cause without the decryption it works fine. I have added the decryption code. For decryption I am using NSData+CommonCrypto library (it's non ARC) but my project is in ARC.</p>