-
Notifications
You must be signed in to change notification settings - Fork 93
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
Please refactor your unwrapping optionals #228
Comments
Thanks for the bug report @AFcgi, this sounds reasonable to me. |
Actually, after thinking about this more, |
Hi @bsudekum, |
Related: mapbox/MapboxGeocoder.swift#106. We should replace most of the force-unwrapping and assertions with exceptions, reserving assertions for things that are entirely within the control of the client-side library (and not due to a malformed response or an error in the application code). |
@1ec5 asserting would not really help @AFcgi out here, correct? |
To clarify:
In general, this means that initializers would be failable and non-initializers would have more assertions. |
Migrating to JSONDecoder entails making the initializers failable. #221 still force-unwraps some things, but it should be much easier to throw instead now. /cc @frederoni |
#382 adopts Codable and eliminates nearly all assertions and upfront optional unwrapping. |
I use MapboxDirections 0.15.1. After response my crashed with an unwrapping optional issue in MBRouteStep line 600.
let drivingSide = DrivingSide(description: json["driving_side"] as! String) ?? .right
I resolve the issue by:
let drivingSide = DrivingSide(description: json["driving_side"] as? String ?? "") ?? .right
I can imaging that they are many other optional issues in the project.
The text was updated successfully, but these errors were encountered: