PDA

View Full Version : Is there any way to stop a running function?




Soulstorm
Oct 5, 2009, 05:09 PM
I want to make an application that works like this:

On entering a view in the program the application will begin downloading some data from the internet. This happens in the background. However, since the data to be downloaded may require some waiting, I want to provide the user the ability to leave this section of the application.

So, what I need is a way to stop the downloading of data from the network after the download has began. Is there any class I can use for that? Right now I am using the NSURL class with "initWithContentsOfURL" method to obtain the data from the internet.

Any ideas?



PhoneyDeveloper
Oct 5, 2009, 05:23 PM
Use NSURLConnection's async loading method. It has a cancel method that you can use if the connection isn't complete and you want to stop the download.

Soulstorm
Oct 6, 2009, 03:39 AM
I will. thanks.