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
Improve object lookup #21
Conversation
@@ -1,6 +1,11 @@ | |||
import Foundation | |||
import Sugar | |||
|
|||
public typealias OptionalString = Optional<String> |
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.
@zenangst Is it used?
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.
Oh, I think I used them when going with the other approach, the one where you had object.value("firstName", OptionalString.self)
. These should be removed now, good catch!
Think I'll just merge this an start working on #23. This might change before it's ready for release anyways. |
This PR adds a new method on
Inspectable
objects.It can be used to safely get values via key from any object that conforms to the
Inspectable
protocol.Example
Implementation
The method
throws
to make sure that you are getting the correct value type back.As an added bonus, the error message that the method throws should give you enough information to point you to the right direction of what when wrong when trying to get the value.
Failure example
Would render this error message: