'init(start:end:)' is deprecated: it will be removed in Swift 3. Use the '..<' operator

后端 未结 6 578
予麋鹿
予麋鹿 2020-12-04 20:54

I\'m using the following code:

var continousDigitsRange:Range = Range(start: 0, end: 0)

Since update to Xcode 7.3 (Sw

6条回答
  •  眼角桃花
    2020-12-04 21:30

    Adding some points with reference to swift 3.0

    //Countable Range Example.

    let range1 = 0..<5

    Countable Closed Range Example

    let range2 = 0...5
    

    //Range from bounds

    let range = Range(uncheckedBounds: (range1.lowerBound,range1.upperBound))
    

    //To get the distance from substringRange.

    let str = "Hello, how are you"
    let substringRange = str.characters.indices
    

    // Below Swift 3.0

    let length = substringRange.distance(from: substringRange.startIndex, to: substringRange.endIndex)
    

    //For Swift 3.0

    let length2 = str.distance(from: substringRange.startIndex, to: substringRange.endIndex)
    

提交回复
热议问题