Swift – Downloading video with downloadTaskWithURL

Please check comments through the code: Xcode 8 • Swift 3 import UIKit import Photos class ViewController: UIViewController { func downloadVideoLinkAndCreateAsset(_ videoLink: String) { // use guard to make sure you have a valid url guard let videoURL = URL(string: videoLink) else { return } guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { … Read more

Showing the file download progress with NSURLSessionDataTask

You need to implement following delegates: <NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate> Also need to create two properties: @property (nonatomic, retain) NSMutableData *dataToDownload; @property (nonatomic) float downloadSize; – (void)viewDidLoad { [super viewDidLoad]; NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]]; NSURL *url = [NSURL URLWithString: @”your url”]; NSURLSessionDataTask *dataTask = … Read more