xcode - stringByReplacingOccurencesOfString() for Swift 3.0 -
i'm having problem when using stringbyreplacingoccurencesofstring()
latest version of xcode 8.2 beta. when using function, xcode showing value type of string has no member.
var clockworksmsurl = "https://api.clockworksms.com/http/send.aspx?" + "key=123456789abcd" + "to=" + usersnumber! + "&content=" + userstextmessage! clockworksmsurl.stringbyreplacingoccurrencesofstring(" ", withstring: "+") var clockworksmsurlconvert = nsurl(string: clockworksmsurl)
any ideas?
you can fix snippet using ...
clockworksmsurl.replacingoccurrences(of: " ", with: "+")
swift 3 changed way how objc apis imported.
please note there issues code posted:
- the result of
replacingoccurrences
discarded. - there more characters escaped.
urlcompontents
exposes safer ways construct urls.
Comments
Post a Comment