Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Warnings about deprecated function #112

Open
moshegutman opened this issue Feb 22, 2018 · 2 comments
Open

Warnings about deprecated function #112

moshegutman opened this issue Feb 22, 2018 · 2 comments

Comments

@moshegutman
Copy link

I'm getting the following warning about substring(to: ) being deprecated.

'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range upto' operator.

It's inside the readResponse() function

if let r = line.range(of: ":") {
    key = trim(line.substring(to: r.lowerBound))
    value = trim(line.substring(from: r.upperBound))
}
@moshegutman
Copy link
Author

I think the fix according to https://stackoverflow.com/questions/45562662/how-can-i-use-string-slicing-subscripts-in-swift-4 is:

if let r = line.range(of: ":") {
    key = trim(String(line[..<r.lowerBound]))
    value = trim(String(line[r.upperBound...]))
}

@strikerEng
Copy link

Wish I read this before I just submitted the same issue. Should I keep it open because it has not been fixed ?

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

No branches or pull requests

2 participants