-
Notifications
You must be signed in to change notification settings - Fork 47
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
Update to Swift 3 #40
Changes from 14 commits
1d8e71f
c7df0e4
e720a02
9bf294c
16a3924
a4af7a2
d8764b1
92a40ff
a3e7741
39f8d46
ebbafc3
51eb803
f585b12
ca0909a
76bb282
92e20f7
89f4e49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,25 @@ import Foundation | |
|
||
extension String { | ||
|
||
func split(delimiter: String) -> [String] { | ||
let components = componentsSeparatedByString(delimiter) | ||
func split(_ delimiter: String) -> [String] { | ||
let components = self.components(separatedBy: delimiter) | ||
return components != [""] ? components : [] | ||
} | ||
|
||
func replace(string: String, with withString: String) -> String { | ||
return stringByReplacingOccurrencesOfString(string, withString: withString) | ||
func replace(_ string: String, with withString: String) -> String { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a syntactic sugar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but it makes less sense in Swift 3 I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, lets get rid of the Sugar that are fixed by Apple in Swift 3. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @onmyway133 Would you mind to remove this functions an use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
return replacingOccurrences(of: string, with: withString) | ||
} | ||
|
||
func queryParameters() -> [String: String] { | ||
var parameters = [String: String]() | ||
|
||
let separatorCharacters = NSCharacterSet(charactersInString: "&;") | ||
self.componentsSeparatedByCharactersInSet(separatorCharacters).forEach { (pair) in | ||
let separatorCharacters = CharacterSet(charactersIn: "&;") | ||
self.components(separatedBy: separatorCharacters).forEach { (pair) in | ||
|
||
if let equalSeparator = pair.rangeOfString("=") { | ||
let name = pair.substringToIndex(equalSeparator.startIndex) | ||
let value = pair.substringFromIndex(equalSeparator.startIndex.advancedBy(1)) | ||
let cleaned = value.stringByRemovingPercentEncoding ?? value | ||
if let equalSeparator = pair.range(of: "=") { | ||
let name = pair.substring(to: equalSeparator.lowerBound) | ||
let value = pair.substring(from: pair.index(equalSeparator.lowerBound, offsetBy: 1)) | ||
let cleaned = value.removingPercentEncoding ?? value | ||
|
||
parameters[name] = cleaned | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks