iOS Downloading Videos and saving in Application Support folder

Posted by Satyam svv on Stack Overflow See other posts from Stack Overflow or by Satyam svv
Published on 2012-10-27T04:54:59Z Indexed on 2012/10/27 5:01 UTC
Read the original article Hit count: 180

In my application, i've to download videos around 10 to my application and play accordingly. Each video is around 50 MB.
I'm using following code and then after downloading the video, i'm saving it to Application support folder to avoid icloud sync. But the problem is that when downloading the videos its crashing.

   [NSURLConnection sendAsynchronousRequest:req queue:[[NSOperationQueue alloc] init]  completionHandler:^(NSURLResponse *response, NSData *rcvdDat, NSError * err) 
     {
      .
      .
      .
     }

What I'm thinking is that, while downloading the video, it resides in memory and so the total memory occupying by the app is increasing. Finally iOS is making the app to close. I would like to download the video and when ever a stream of data received, write to temp file and when completes move it to application support folder. Can some one help me on how to write it to file and save it at the end?
I cannot use 3rd party libraries (unless its small) due to legal issues.

© Stack Overflow or respective owner

Related posts about ios

Related posts about file-download