juancho
03/01/2019, 2:59 AMSWIFT CODE:
let originalString = "test/test"
let escapedString = originalString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
print(escapedString!)
I found that this function is defined as an extension in a class called StringProtocol
extension StringProtocol where Self.Index == String.Index {
Any idea how can I get access to this function from Kotlin Native? Thanks!juancho
03/01/2019, 3:26 AMfun String.encode(): String? {
return (this as? NSString)?.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet)
}
juancho
03/01/2019, 3:27 AMThis cast can never success
svyatoslav.scherbina
03/01/2019, 7:48 AMKnown issue, this warning is wrong. Your Kotlin function definition is fine.This cast can never success
juancho
03/01/2019, 2:09 PMsvyatoslav.scherbina
03/01/2019, 2:14 PMstringByAddingPercentEncodingWithAllowedCharacters
. You can ensure this by switching language between Swift and Objective-C in the documentation for one of these functions.juancho
03/01/2019, 2:15 PMoriginalString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
I end up using the other one that you mentioned as an alternativejuancho
03/01/2019, 2:16 PM