Avatar
norio_nomura 10/1/2018 1:34 PM
extension JSONDecoder.DateDecodingStrategy { @available(OSX, obsoleted: 10.11) static var iso8601 = JSONDecoder.DateDecodingStrategy.formatted({ let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" formatter.timeZone = TimeZone(secondsFromGMT: 0) return formatter }()) } とかやってみたけど、候補を探すときに@availableを考慮してくれなくてダメだった。 Compile Swift Module 'Foo' (1 sources) /Users/norio/github/Foo/Sources/Foo/Foo.swift:17:37: error: ambiguous use of 'iso8601' decoder.dateDecodingStrategy = .iso8601 ^ Foundation.JSONDecoder:7:14: note: found this candidate case iso8601 ^ /Users/norio/github/Foo/Sources/Foo/Foo.swift:5:16: note: found this candidate static var iso8601 = JSONDecoder.DateDecodingStrategy.formatted({ ^
😭 1