title: Value of type 'String' has no member 'range' in Swift
body: <p>I believe I've run into a Swift versioning issue but I'm not too sure.  The code works in my Xcode platform but not in an online swift compiler.  Has anyone else run into this issue or know what I can use to replace the following lines where I check for a character:</p>
  
  <pre><code>if i == 0 || !((line.range(of: ":") != nil)) 
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>import Foundation
  
  
  
  func hackTheString(line: String){
  
          var maxOpen: Int = 0
          var minOpen: Int = 0
  
          minOpen = 0
          maxOpen = 0
          let i = 0
          while i &lt; line.characters.count {
              for character in line.characters {
                  if character == "(" {
                      maxOpen += 1
                      if i == 0 || !((line.range(of: ":") != nil)) {
                          minOpen += 1
                          }
                      }
                  else if character == ")"{
                      minOpen = max(0,minOpen-1)
  
                      if i == 0 || !((line.range(of: ":") != nil)){
                          maxOpen -= 1;
                          }
                      if maxOpen &lt; 0{
                          break
                      }
                  }
              }
  
          if maxOpen &gt;= 0 &amp;&amp; minOpen == 0{
              print("YES")
              }else{
                  print("NO")
              }
          }
      }
  
  
  while let line = readLine() {
  
  
      print(hackTheString(line))
  
  }
  </code></pre>
  
  <p>The error given from the online compiler is: </p>
  
  <pre><code>source.swift:17:37: error: value of type 'String' has no member 'range'
                      if i == 0 || !((line.range(of: ":") != nil)) {
                                      ^~~~ ~~~~~
  source.swift:24:37: error: value of type 'String' has no member 'range'
                      if i == 0 || !((line.range(of: ":") != nil)){
                                      ^~~~ ~~~~~
  </code></pre>