Compare two strings?

This question already has an answer here:

  • How do I check if a string contains another string in Swift? 23 answers
  • Substring from a string in swift | Index of a substring in a string 6 answers

  • if "test".contains("es") {
        //...                
    }
    

    Don't use NSString in Swift. Use String (which is also the default when you create Strings).

    Anyway, contains() is what you're looking for.

    if "test".contains("es") {
        // this will run
    }
    
    链接地址: http://www.djcxy.com/p/74008.html

    上一篇: 内置NSString方法来比较类似字符的数量

    下一篇: 比较两个字符串?