'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range upto' operator
The problem with your attempt to use localNumber[..<3]
is that you can't pass an Int
as the range. You need to pass a String.Index
.
Your code needs to be:
let index = localNumber.index(localNumber.startIndex, offsetBy: 3)self.areaCodeLael.text = localNumber[..<index]
Also note that you do not want the !
operator after text
.