Created
December 21, 2015 17:51
-
-
Save abbeyjackson/d0a4eaad8a11df707428 to your computer and use it in GitHub Desktop.
Return a NSRange from String instead of a Range<Index>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func nsRangeOfString(string: String) -> NSRange? { | |
guard let range = self.rangeOfString(string) else { return nil } | |
let startIndex = self.startIndex.distanceTo(range.startIndex) | |
return NSRange(location: startIndex, length: range.count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment