今天看到问Swift问题:  Initializer for conditional binding must have Optional type, not 'String'

以前没遇到过这个问题,这不赶紧写个demo验证一下,弄懂什么问题吧,算是积累小知识了.

Initializer for conditional binding must have Optional type, not 'String'

报错原因:

if 里面的判断类型必须是Optional类型。

解决方法:

Initializer for conditional binding must have Optional type, not 'String'

注意不仅是if let会报错,guard let 同样是这样...

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
相关资源
相似解决方案