简体   繁体   中英

Is it possible to start an NSURLConnection multiple times?

I'm setting up a class to manage the download of some data. Due to the spec it has to be downloaded multiple times (as it may change). I can't change that but I have a question.

If I create a class that is dedicated to downloading the data so it is an NSURLConnectionDataDelegate etc...

Can I store the NSURLConnection as a property and set it up in the init and then reuse the same connection each time?

Or should I store the NSURLRequest and use the same request in a new connection each time?

The reason I ask is that the docs for NSURLConnection state...

"You cannot reschedule a connection after it has started."

and I'm not 100% sure what that means.

Yes, as long as each time you have a unique object that creates the NSURLConnection. This is simply stating you can't have the same object "reschedule" a connection, mid connection.

Never hurts to run a simple test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM