Swift 4 'substring(from:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator

前端 未结 7 2108
情话喂你
情话喂你 2020-12-30 23:59

i\'ve just converted my little app but i\'ve found this error: \'substring(from:)\' is deprecated: Please use String slicing subscript with a \'partial range from\' operator

7条回答
  •  抹茶落季
    2020-12-31 00:22

    It means you should use the new partial range operator as your upperBound:

    let str =  "Hello World !!!"
    if let index = str.range(of: "Hello ")?.upperBound {
       let string = String(str[index...])  // "World !!!"
    }
    

    In your case

    cell.detailTextLabel?.text = String(thisRecord.pubDate[index...]))
    

提交回复
热议问题