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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -