// MARK: Telegram Share
@objc func sharetoTg() {
if dateToday.isGreater(than: vc.defaults.value(forKey: "NextDay4") as! Date) {
tbShare.nextDay4 = Date(timeInterval: dateInterval, since: dateToday)
...
let alert = UIAlertController(title: nil, message: "Share on Telegram".localized, preferredStyle: .alert)
let action = UIAlertAction(title: "Done".localized, style: .default) { (action) in
...
}
alert.addAction(action)
...
} else {
let alert = UIAlertController(title: nil, message: "You can share ".localized + "after 15 minutes")", preferredStyle: .alert)
let action = UIAlertAction(title: "OK".localized, style: .default)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
}
URLSession.shared.downloadTask(with: videoURL) { (location, response, error) -> Void in
// use guard to unwrap your optional url
guard let location = location else { return }
// create a deatination url with the server response suggested file name
let destinationURL = documentsDirectoryURL.appendingPathComponent(response?.suggestedFilename ?? videoURL.lastPathComponent)
if FileManager.fileExists(atPath: destinationURL.path) {
try FileManager.removeItem(at: destinationURL)
}
do {
try FileManager.default.moveItem(at: location, to: destinationURL)
Invalid conversion from throwing function of type '(_, _, _) throws -> Void' to non-throwing function type '(URL?, URLResponse?, Error?) -> Void'