首页 > 技术文章 > 'substring(from:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator.

luoxiaofu 2017-10-12 13:59 原文

let newStr = String(str[..<index]) // = str.substring(to: index) In Swift 3
let newStr = String(str[index...]) // = str.substring(from: index) In Swif 3
let newStr = String(str[range]) // = str.substring(with: range) In Swift 3

推荐阅读