Swift: Testing optionals for nil

前端 未结 14 677
攒了一身酷
攒了一身酷 2020-12-08 08:51

I\'m using Xcode 6 Beta 4. I have this weird situation where I cannot figure out how to appropriately test for optionals.

If I have an optional xyz, is the correct w

14条回答
  •  清歌不尽
    2020-12-08 09:21

    Now you can do in swift the following thing which allows you to regain a little bit of the objective-c if nil else

    if textfieldDate.text?.isEmpty ?? true {
    
    }
    

提交回复
热议问题