-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to Swift 4 #131
Migrate to Swift 4 #131
Conversation
efae1dc
to
e6b5e0f
Compare
Write extensions to decode arrays and dictionarys Reinstate self made hex string transform
e6b5e0f
to
ee46f83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments about the GCColor
implementation and some more about lesser things ...
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda liked the new line here ... :(
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
fileName = try container.decode(String.self, forKey: .fileName) | ||
contentType = try container.decode(String.self, forKey: .contentType) | ||
details = try container.decode(Details.self, forKey: .details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle decoding the imageInfo
too? Or would you need a init
on the Details
object too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It indeed does handle the imageInfo! All decoding decodes and properties that are also Decodable
which ImageInfo
is.
Sources/Contentful/Client.swift
Outdated
let map = Map(mappingType: .fromJSON, JSON: json, context: localizationContext) | ||
|
||
let jsonDecoder = Client.jsonDecoderWithoutContext // JSONDecoder() | ||
jsonDecoder.userInfo[LocalizableResource.localizationContextKey] = localizationContext | ||
|
||
// Use `Mappable` failable initialzer to optional rather throwing `ImmutableMappable` initializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this comment is still acurate: Do you still use a mappable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch.
Sources/Contentful/Client.swift
Outdated
} catch _ { | ||
completion(.error(SDKError.unparseableJSON(data: data, errorMessage: ""))) | ||
completion(Result.error(SDKError.unparseableJSON(data: data, errorMessage: ""))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this general catch
was in here before, but I am wondering if this can also indicate another error, something which is not a DecodingError
but an Out of memory
. So maybe then all the unparseableJSON
-Error might be misleading? (It is actually parsable, but something else went wrong ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have consolidated to one catch statement now.
|
||
super.init(dateFormatter: formatter) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
|
||
|
||
// Use CGColor instead of UIColor to enable cross-platform compatibility: macOS, iOS, tvOS, watchOS. | ||
internal extension CGColor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does coco/darwin handle alpha components? If so, should they be part of your color model?
var result = left | ||
right.forEach { (key, value) in result[key] = value } | ||
return result | ||
} | ||
|
||
internal func +<K: Hashable, V> (left: [K: V], right: [K: V]) -> [K: V] { | ||
internal func +<K, V> (left: [K: V], right: [K: V]) -> [K: V] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear this might not the right implementation of +
. Also I feel I stumbled upon this before: Is left passed in as a reference or as a copy?
If it is a copy (aka changing it in here, does not change the variable outside) then I take back my comment and bow over in front of swift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a copy in swift since dictionaries are structs. when you pass one in, it is copied. we've had this conversation before ;-)
|
||
|
||
// Use CGColor instead of UIColor to enable cross-platform compatibility: macOS, iOS, tvOS, watchOS. | ||
internal extension CGColor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: I would love to see tests about this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call ;-)
expect(dogs.count).to(equal(1)) | ||
expect(dogs.first?.name).to(equal("Jake")) | ||
case .error(let error): | ||
fail("Should not throw an error \(error)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does failing fullfill the expectation too? Or would it wait for ever in here now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the expectation is fulfilled outside of the switch: no matter the case, it is fulfilled.
QueryTests.client.fetchMappedEntries(with: query).then { citiesResponse in | ||
QueryTests.client.fetchMappedEntries(with: query) { result in | ||
switch result { | ||
case .success(let citiesResponse): | ||
let cities = citiesResponse.items |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you missed an indentation here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.