سؤال

How do I do partial download of JSON Data using NSConnection ?

هل كانت مفيدة؟

المحلول

Can you provide a little bit more information about what you're trying to accomplish? I assume that you mean you would like to start processing the json before it is completely finished downloading. One thing you could look at the didReceiveData method that you can implement for the NSUrlConnection's delegate:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

You could parse through the data as it comes down, and when you have enough JSON to parse you could begin processing it well before it is completely downloaded. Of course, that means you will probably have to parse the json string yourself rather than use one of the json parsers that expects a fully formed json string.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top