-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
@@ -547,7 +547,7 @@ public class RouteStep: NSObject, NSSecureCoding { | |||
self.coordinates = coordinates | |||
} | |||
|
|||
internal convenience init(json: JSONDictionary) { | |||
public convenience init(json: [ String: Any ]) { |
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.
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.
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.
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
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.
That’s fine, but then you need to use [String: AnyObject]
in Swift 2.3 and [String: Any]
only in Swift 3.
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.
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 ]) { |
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.
All public symbols should have documentation comments.
For consistency, the JSON initializers for Route and RouteLeg should be exposed publicly too. |
This allows using RouteStep/RouteLeg easier in external tests
23c25cc
to
7a77fe4
Compare
@1ec5 |
This ensures that generated documentation puts these methods in the right order.
Is it possible to make Route conform to Decodable ? |
What's the best way to parse JSON object into Route object ? |
|
This allows using RouteStep easier in tests