Skip to content
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

Merged
merged 10 commits into from
Oct 2, 2017
Merged

Migrate to Swift 4 #131

merged 10 commits into from
Oct 2, 2017

Conversation

loudmouth
Copy link
Contributor

@loudmouth loudmouth commented Sep 28, 2017

No description provided.

@loudmouth loudmouth force-pushed the improvement/swift-4 branch 2 times, most recently from efae1dc to e6b5e0f Compare October 2, 2017 08:57
@loudmouth loudmouth force-pushed the improvement/swift-4 branch from e6b5e0f to ee46f83 Compare October 2, 2017 09:17
@loudmouth loudmouth self-assigned this Oct 2, 2017
Copy link
Contributor

@mariobodemann mariobodemann left a 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 ...

}

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch.

} catch _ {
completion(.error(SDKError.unparseableJSON(data: data, errorMessage: "")))
completion(Result.error(SDKError.unparseableJSON(data: data, errorMessage: "")))
Copy link
Contributor

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 ...

Copy link
Contributor Author

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)
}
}
Copy link
Contributor

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 {
Copy link
Contributor

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] {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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...

Copy link
Contributor Author

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)")
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@mariobodemann mariobodemann left a comment

Choose a reason for hiding this comment

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

:shipit:

@loudmouth loudmouth merged commit 624c6f3 into master Oct 2, 2017
@loudmouth loudmouth deleted the improvement/swift-4 branch October 2, 2017 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants