【问题标题】:How to check if a string only contains 1 character using swift如何使用swift检查字符串是否仅包含1个字符
【发布时间】:2016-05-21 15:25:32
【问题描述】:

如何使用 swift 中的 if 语句检查字符串是否仅包含 1 个字符?

【问题讨论】:

    标签: string swift if-statement character


    【解决方案1】:

    很简单,用这个:

    var str:String = "a"
    
    if str.characters.count == 1 {
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-03
      • 2017-12-16
      • 2016-01-25
      • 2010-12-19
      • 2013-07-26
      • 1970-01-01
      相关资源
      最近更新 更多