How to print a string from plist without “Optional”?

前端 未结 6 1780
遥遥无期
遥遥无期 2020-12-10 01:46

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

6条回答
  •  一整个雨季
    2020-12-10 02:34

    Another, slightly more compact, way (clearly debatable, but it's at least a single liner)

    (result["ip"] ?? "unavailable").description.

    In theory result["ip"] ?? "unavailable" should have work too, but it doesn't, unless in 2.2

    Of course, replace "unavailable" with whatever suits you: "nil", "not found" etc

提交回复
热议问题