Author Topic: How do I use the String.compare method in Swift?  (Read 4642 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How do I use the String.compare method in Swift?
« on: March 02, 2015, 06:05:15 PM »
When using the String.compare method in Swift, rather than using NSCaseInsensitiveSearch-type values for the options argument, use the NSStringCompareOptions enum values instead. For example:

Code: [Select]
myString.compare(searchString, options: NSStringCompareOptions.CaseInsensitiveSearch, range: a...b, locale: nil)
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11