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

Make RouteStep json initialize public #92

Merged
merged 3 commits into from
Nov 11, 2016
Merged

Make RouteStep json initialize public #92

merged 3 commits into from
Nov 11, 2016

Conversation

freenerd
Copy link
Contributor

@freenerd freenerd commented Nov 9, 2016

This allows using RouteStep easier in tests

@@ -547,7 +547,7 @@ public class RouteStep: NSObject, NSSecureCoding {
self.coordinates = coordinates
}

internal convenience init(json: JSONDictionary) {
public convenience init(json: [ String: Any ]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change [String: Any] back to JSONDictionary: in this library, JSONDictionary is a typedef for [String: AnyObject]. JSON objects are represented as [String: AnyObject] in Swift 2.3 but as [String: Any] in Swift 3.

This is why all the builds are failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSONDictionary is a private typealias in MBDirections:

MBRouteStep.swift:570:24: Initializer cannot be declared public because its parameter uses an internal type

Using init(json: JSONDictionary in external tests is prohibited by that. Not sure how to make typealias public (they should be by default?), but the easier solution was to change the function signature without the typealias

Copy link
Contributor

Choose a reason for hiding this comment

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

That’s fine, but then you need to use [String: AnyObject] in Swift 2.3 and [String: Any] only in Swift 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to [String: AnyObject]

@@ -547,7 +547,7 @@ public class RouteStep: NSObject, NSSecureCoding {
self.coordinates = coordinates
}

internal convenience init(json: JSONDictionary) {
public convenience init(json: [ String: Any ]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

All public symbols should have documentation comments.

@1ec5
Copy link
Contributor

1ec5 commented Nov 10, 2016

For consistency, the JSON initializers for Route and RouteLeg should be exposed publicly too.

This allows using RouteStep/RouteLeg easier in external tests
@freenerd
Copy link
Contributor Author

@1ec5 Route already had a public json initializer. RouteLeg now has as well. Please feel free to adjust the inline comments.

freenerd added a commit that referenced this pull request Nov 10, 2016
This ensures that generated documentation puts these methods in the right order.
@freenerd freenerd merged commit 79f5882 into master Nov 11, 2016
@freenerd freenerd deleted the public-route-step branch November 11, 2016 12:42
freenerd added a commit that referenced this pull request Nov 11, 2016
@gregoireLem
Copy link

Is it possible to make Route conform to Decodable ?

@gregoireLem
Copy link

gregoireLem commented Mar 13, 2018

What's the best way to parse JSON object into Route object ?
thx

@1ec5
Copy link
Contributor

1ec5 commented Mar 13, 2018

Is it possible to make Route conform to Decodable ?

#221

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.

3 participants