1

i am struggling... What is wrong? "Unexpected non-void return value in void function"

Thanks a lot for helping!!!

import Foundation

func lastmod() -> String {

    let url = URL(string: "https://www.url.de/pic1.png")
    let urlSession = URLSession.shared
    let task = urlSession.dataTask(with: url!) { (data, response, error) in
    guard let data = data, error == nil else {
        debugPrint("Fehler beim Laden von \(String(describing: url))", String(describing: error))
        return
    }
    if let response = response
        {
        let httpResponse = response as! HTTPURLResponse
        let str = String(describing: httpResponse.value(forHTTPHeaderField: "Last-Modified"))
        print(str)
        return str
        }
    }
    task.resume()
}
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
sco0o
  • 11
  • 2

0 Answers0