Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'advanced(by:)' is unavailable (Swift 4) #56

Closed
wspl opened this issue Jul 27, 2017 · 2 comments
Closed

'advanced(by:)' is unavailable (Swift 4) #56

wspl opened this issue Jul 27, 2017 · 2 comments

Comments

@wspl
Copy link
Contributor

wspl commented Jul 27, 2017

In MatchResult.swift 103~108:

  private func utf16Range(from range: NSRange) -> Range<String.UTF16Index>? {
    guard range.location != NSNotFound else { return nil }
    let start = string.startIndex.advanced(by: range.location)
    let end = start.advanced(by: range.length)
    return start..<end
  }

106:21:
'advanced(by:)' is unavailable
'advanced(by:)' was obsoleted in Swift 4.0

@wspl wspl changed the title 'advanced(by:)' is unavailable 'advanced(by:)' is unavailable (Swift 4) Jul 27, 2017
@wspl
Copy link
Contributor Author

wspl commented Jul 27, 2017

Solution:

  private func utf16Range(from range: NSRange) -> Range<String.UTF16Index>? {
    guard range.location != NSNotFound else { return nil }
    let start = string.index(string.startIndex, offsetBy: range.location)
    let end = string.index(start, offsetBy: range.length)
    return start..<end
  }

It works well for me.

@sharplet
Copy link
Owner

Fixed by #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants