无法在 Swift3 中不带参数调用 'ISO8601DateFormatter'

Cannot invoke 'ISO8601DateFormatter' with no arguments in Swift3

将我的 Swift2 项目转换为 Swift3 时,我在 XCode 中收到以下代码错误:

let dateFormatter = ISO8601DateFormatter()

Cannot invoke 'ISO8601DateFormatter' with no arguments in Swift3

在 Playground 中,这可以正常编译。有没有人对如何解决这个问题有任何想法?所有产生错误的 类 也导入了 Alamofire。不确定这是否会产生影响。

试试这个

 let date = Date()
    let isoformatter = ISO8601DateFormatter.init()
    let timeStr = isoformatter.string(from: date)

    // Generete Date from string that being generated
    let dateFromString = isoformatter.date(from: timeStr)