开发者

NSMutableURLRequest with large files

I'm writing an iPhone app that requests data from a web service, and in order to get that data, I'm using NSMutableURLRequest.

The problem that I am having is that the a开发者_StackOverflowmount of data being requested is quite large (~11Mb), and this is causing my app to be killed by the OS.

Is there any way of streaming the data in a way that will allow me to process chunks of it, or should I just split the request over several separate requests in order to prevent the memory load spiking?


Think about converting your use of NSMutableURLRequest to an NSURLConnection. That class provides a way to specify a delegate object that will receive a series of connection:didReceiveData: messages, each of which will have some chunk of data from your web server. You can implement this method in your delegate in such a way that it will process data as it becomes available while still waiting for more data from the connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜