ARTICLES

Swift 4 substring

After converting my Swift 3 project to Swift 4 I received the warning:

‘substring(from:)’ is deprecated: Please use String slicing subscript with a ‘partial range from’ operator.

The old Swift 3 code was

let range = str.range(of:"Some ")
let index = range!.upperBound
let subStr = str.substring(from: index)

The new Swift 4 code for substring is:

let str = "Some String"
let range = str.range(of:"Some ")
let index = range!.upperBound
let subStr = String(str[index...])


Our Products

Kitemetrics
Keyword level attribution for Apple Search Ads. Optimize your bids and increase your revenue. Sign up for free at kitemetrics.com.

White Noise and Deep Sleep Sounds
Calming and relaxing sounds that will help you sleep like a baby tonight.
Download for free from the App Store.
Get it on Google Play.




Our Sponsors

Get Sleepy
Get Sleepy
The free podcast that puts you to sleep with meditative bedtime stories. Listen at getsleepy.com.