标签: string swift if-statement character
如何使用swift中的if语句检查字符串是否只包含1个字符?
答案 0 :(得分:1)
这很容易,请使用:
var str:String = "a" if str.characters.count == 1 { }