網(wǎng)上很多資料都是錯的,Xcode
if string.text!.contains(".") {
print("字符串包含.")
}
附Documentation解釋
Finding Substrings
func hasPrefix(String)
Returns a Boolean value indicating whether the string begins with the specified prefix.
func hasSuffix(String)
Returns a Boolean value indicating whether the string ends with the specified suffix.
Finding Characters
func contains(Character)
Returns a Boolean value indicating whether the sequence contains the given element.
func contains(where: (Character) -> Bool)
Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.