I load a value from a dictionary in a plist but when I print it to the console, it prints: Optional(Monday Title) rather than just \"Monday Title\".
How can I get ri
From Swift 3, you can use String(describing:) to print out optional value. But the syntax is quite suck and the result isn't easy to see in console log.
So that I create a extension of Optional to make a consistent nil value.
extension Optional {
var logable: Any {
switch self {
case .none:
return "⁉️" // Change you whatever you want
case let .some(value):
return value
}
}
}
How to use:
var a, b: Int?
a = nil
b = 1000
print("a: ", a.logable)
print("b: ", b.logable)
Result:
a: ⁉️
b: 1000