zhiming jiang zhiming jiang - 28 days ago 4x
iOS Question

string like "2016-06-06" to Date object in Swift 3

I am new to swift 3, the way I found is

extension Date
init(dateString:String) {
let dateStringFormatter = DateFormatter()
dateStringFormatter.dateFormat = "yyyy-MM-dd"
dateStringFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") as Locale!
let d = dateStringFormatter.date(from: dateString)!
self(timeInterval:0, since:d)

in self(timeInterval:0, since:d) raise error Cannot call value of non-function type 'Date'
also I doesn't see this error before. Anyone please help me and explain it


Change to: self.init(timeInterval:0, since:d)