Is there any way to stop a running function?

Discussion in 'iOS Programming' started by Soulstorm, Oct 5, 2009.

  1. Soulstorm macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #1
    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?
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     
  3. Soulstorm thread starter macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005

Share This Page