extension String {
func indexer(from: Int) -> Index {
return self.index(startIndex, offsetBy: from)
}
func substr(from: Int) -> String {
let fromIndex = indexer(from: from)
return substring(from: fromIndex)
}
func substr(to: Int) -> String {
let toIndex = indexer(from: to)
return substring(to: toIndex)
}
func substr(with r: Range<Int>) -> String {
let startIndex = indexer(from: r.lowerBound)
let endIndex = indexer(from: r.upperBound)
return substring(with: startIndex..<endIndex)
}
}
Warning with : 'substring(from:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator.
extension String {
func indexer(from: Int) -> Index {
return self.index(startIndex, offsetBy: from)
}
}
Warning with : 'substring(from:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator.