How do I use NSOperationQueue with NSURLSession?

前端 未结 7 958
别跟我提以往
别跟我提以往 2020-12-04 06:48

I\'m trying to build a bulk image downloader, where images can be added to a queue on the fly to be downloaded, and I can find out the progress and when they\'re done downlo

7条回答
  •  [愿得一人]
    2020-12-04 06:50

    Here's a sample project using NSOperation with NSURLSession: https://github.com/MacMark/Operations-Demo

    For background sessions you can resurrect the NSOperation by using the session's identifier in this callback:

    - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler {
       // Restore the NSOperation that matches the identifier
       // Let the NSOperation call the completionHandler when it finishes
    }
    

提交回复
热议问题