Continue download in background

后端 未结 3 713
余生分开走
余生分开走 2021-02-07 21:13

I am creating an application wherein I am downloading some data from server. While going in background I want that connection should continue running so that data can be downloa

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 21:46

    I don't know how you handle your data downloading exactly. But you can take a look at ASIHTTPRequest. It is very simple and straightforward, and works with ARC if you set the compiler flags to -fno-objc-arc. With this you only have to use

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setShouldContinueWhenAppEntersBackground:YES]; //For iOS 4.0 and up 
    

    And that works.

    Here you can see how ASIHTTPRequest works

    Hope it helps!

提交回复
热议问题