0

I have a large file that I receive through a web service that I am trying to write to disk. I can write most files to disk, but this and other files of this size (or greater) seem to be causing issues. The app will crash when I try to convert the string of bits to NSData after receiving memory warnings. Here's the code I am using:

NSString *bits = /*string of file stream*/;
NSData *fileData = [[NSData alloc] initWithBase64EncodedString:bits options:0];

The app will crash when trying to create the fileData variable. Is there a standard to doing this process that I may not be following or is there a trick to working with large files?

Thank you in advance! This issue has been really bothering me.

A Little More Information

It seems accessing the bits string too often will cause the crash due to the large amount of data in the file stream string. I'm not too sure how to deal with this.

user3002092
  • 495
  • 2
  • 11
  • 29
  • 2
    Write it in smaller chunks so you don't have it all in memory at once. – rmaddy Mar 16 '15 at 17:34
  • @rmaddy I believe I may have seen something like that before. Do you have an example I can look at or maybe a code snippet? Is that a standard that tends to be used for this kind of issue? – user3002092 Mar 16 '15 at 17:37

0 Answers0