swift字符串截取实例

截取字符串

 let deviceStr = deviceInfoLabel.attributedText?.string

        var device  = ""

        if let len : Range<String.Index> = deviceStr?.range(of: "#"){

            let range :Range<String.Index> = (deviceStr?.startIndex)! ..< len.lowerBound

             device = String(deviceStr![range]) + "#"

        }

 

posted @ 2019-03-06 16:49  不停奔跑的蜗牛  阅读(350)  评论(0编辑  收藏  举报