How do I prevent my text from displaying Optional() in the Swift interpolation?

前端 未结 3 817
星月不相逢
星月不相逢 2021-01-28 09:24

How do I prevent my text from displaying Optional() in the Swift interpolation?

My text displaying is :

---You can only switch properties once all images from Op

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 09:57

    I ended up going with the following because I didn't want to use guard, but I wanted to always display the message:

                var propertyNameStr = ""
                if let propertyName = syncer!.getPropertyConfig()?.propertyName {
                    propertyNameStr = "from \(propertyName) "
                }
                messageText.text = "You can only switch properties once all images \(propertyNameStr)have finished uploading."
    

提交回复
热议问题