'advance' API has been removed in Swift 2.0.
If we use 'advance' API in Swift 2.0, it is throwing error saying 'advance' is unavailable: call the '**advancedBy(n)**' method on the index
.
How to get index using advancedBy API in Swift 2.0?
Below is my scenario:
let startIndex = advance(cardNumber.endIndex, -4)
let lastFourDigitsOfPhoneNumber = phoneNumber.substringFromIndex(startIndex)
You need to call advancedBy
on endIndex
.
let startIndex = cardNumber.endIndex.advancedBy(-4)
let lastFourDigitsOfPhoneNumber = phoneNumber.substringFromIndex(startIndex)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With