I am trying to download a large file using NSURLConnection. Instead of appending the data received in the didReceiveData method to an NSData object I create a file first and write the data to an NSFileHandle fileHandleForWritingAtPath. The problem is that this file does not seem to be present on disk until after connectionDidFinishLoading where I call [handle closeFile] and as such I believe it is being held in memory and the application crashes due to memory problems.
Does anyone know how I can donwload a file and write it to a file bit by bit so as not to use too much memory on the iPhone?