Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ public typealias EncodeResult = (data: Data?, error: Error?)

open class CodableHelper {

open static var dateformatter: DateFormatter?

open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
var returnedDecodable: T? = nil
var returnedError: Error? = nil

let decoder = JSONDecoder()
decoder.dataDecodingStrategy = .base64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed?

if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
if let df = self.dateformatter {
decoder.dateDecodingStrategy = .formatted(df)
} else {
decoder.dataDecodingStrategy = .base64
Copy link

@fl034 fl034 Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DawidvanGraan Why is this inside the else scope?
Shouldn't the dataDecodingStrategy be applied, regardless of the custom date formatter?
Could be a mistake because date and data looks pretty much the same...

if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
}
}

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ public typealias EncodeResult = (data: Data?, error: Error?)

open class CodableHelper {

open static var dateformatter: DateFormatter?

open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
var returnedDecodable: T? = nil
var returnedError: Error? = nil

let decoder = JSONDecoder()
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
if let df = self.dateformatter {
decoder.dateDecodingStrategy = .formatted(df)
} else {
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
}
}

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ public typealias EncodeResult = (data: Data?, error: Error?)

open class CodableHelper {

open static var dateformatter: DateFormatter?

open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
var returnedDecodable: T? = nil
var returnedError: Error? = nil

let decoder = JSONDecoder()
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
if let df = self.dateformatter {
decoder.dateDecodingStrategy = .formatted(df)
} else {
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
}
}

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ public typealias EncodeResult = (data: Data?, error: Error?)

open class CodableHelper {

open static var dateformatter: DateFormatter?

open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
var returnedDecodable: T? = nil
var returnedError: Error? = nil

let decoder = JSONDecoder()
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
if let df = self.dateformatter {
decoder.dateDecodingStrategy = .formatted(df)
} else {
decoder.dataDecodingStrategy = .base64
if #available(iOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
}
}

do {
Expand Down