In Swift 4 you slice a string into a substring using subscripting . The use of substring(from:) , substring(to:) and substring(with:) are all deprecated.
Read moreHow do you substring a string in Swift?
You can get a substring from a string by using subscripts or a number of other methods (for example, prefix , suffix , split ) . You still need to use String. Index and not an Int index for the range, though. (See my other answer if you need help with that.)14 Kas 2017
Read moreHow do you break a line in Swift?
By default Swift strings can’t span more than one line. One simple way around this is to use the new line character \n , but that only works for strings that are displayed – if you’re just trying to format your string nicely, you should use multi-line strings instead.
Read moreWhat is a substring in Swift?
When you create a slice of a string, a Substring instance is the result. Operating on substrings is fast and efficient because a substring shares its storage with the original string. The Substring type presents the same interface as String , so you can avoid or defer any copying of the string’s contents.
Read more