在 Objective C 中,可以执行以下操作来检查字符串:
if ([myString isEqualToString:@""]) {
NSLog(@"myString IS empty!");
} else {
NSLog(@"myString IS NOT empty, it is: %@", myString);
}
如何在 Swift 中检测空字符串?
最佳答案
现在内置了使用 .isEmpty
检测空字符串的能力:
if emptyString.isEmpty {
print("Nothing to see here")
}
Apple 预发布文档:"Strings and Characters" .
关于swift - 在 Swift 中检查空字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24133157/