title: Number of occurrences of substring in string in Swift
body: <p>My main string is "hello Swift Swift and Swift" and substring is Swift.
  I need to get the number of times the substring "Swift" occurs in the mentioned string.</p>
  
  <p>This code can determine whether the pattern exists.</p>
  
  <pre><code>var string = "hello Swift Swift and Swift"
  
  if string.rangeOfString("Swift") != nil {
      println("exists")
  }
  </code></pre>
  
  <p>Now I need to know the number of occurrence.</p>