There are two uses of range in Swift
1. Convert the string to NSString to use
Here is the conversion of Swift's character to NSString using let str:nsstring = text.string as NSString self.showmessage ("Tap:" + Str.substringwithrange (range))
2. Create using Swift's own range
This is done using Swift's own range, //In this case, the range in Swift is different from OC, which is understood as a relative thought, and below is the starting point for how far away the distance string begins, Intercept distance start or end distance as end let ra = Range (Start:text.string.startIndex.advancedBy (range.location), End: Text.string.startIndex.advancedBy (Range.length + range.location)) self.showmessage ("Tap:" + Text.string.substringWithRange (RA))
It is advisable to use the latter, and if you are familiar with this, you will find the relative ideas in swift more elegant
Use the title of range in Swift