0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

URLSessionの共有は道半ば

Last updated at Posted at 2017-11-14

先日書いたURLSessionの問題は一部解決した。

Storyboardに紐づいたViewControllerクラスにURLSessionDownloadDelegateを追加する形であれば問題が起きなかった。

import UIKit

class ViewController: UIViewController, URLSessionDownloadDelegate {
}

しかし、これではViewControllerに縛られてしまう。複数のViewControllerでデータのダウンロード処理部分を共有したい。そのためには独立したクラスでURLSessionを扱えば、共有できるのではないかと考えている。

class aViewCtrl <-> class sharedURLSession <-> class bViewCtrl

非同期処理、並列処理の扱いは難しい。参考2を読み解くことが解決の糸口に感じる。


参考

  1. [Swift3.0] URLSessionによるファイルダウンロードと進捗プログレスバーの表示 | JoyPlotドキュメント

  2. RLSessionDownloadTask でちょっと大きめなデータでも寝ている間にダウンロード - Qiita

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?