string - Swift - how to convert hyphen/minus sign into + sign -
i obtaining address in string variable ios reverse geocoding below code.
clgeocoder().reversegeocodelocation(imagelocation, completionhandler: {(placemarks, error) in dispatch_async(dispatch_get_main_queue(), { if (error != nil) {println("reverse geodcode fail: \(error.localizeddescription)") textfield.placeholder = "address not found." } else { if placemarks.count > 0 { var placemark:clplacemark = placemarks[0] as! clplacemark var locationaddress:nsarray = placemark.addressdictionary["formattedaddresslines"] as! nsarray var tmpaddress = locationaddress.componentsjoinedbystring("\n") textfield.text = tmpaddress string } } }) })
tmpaddress variable has address - "2362-2658 w 12th st\ncity, state 20301\ncountry name"
i need change 2362-2658 2362+2658 in tmpaddress variable not able
tmpaddress = tmpaddress.stringbyreplacingoccurrencesofstring("-", withstring: "+")
or
tmpaddress = tmpaddress.stringbyreplacingoccurrencesofstring("\u{2212}", withstring: " ")
please can suggest why stringbyreplacingoccurrencesofstring above not working , how can accomplished.
tmpaddress = tmpaddress.stringbyreplacingoccurrencesofstring("-", withstring: "+")
this replaces '-' '+'
the first parameter search string, , second replacement string.
Comments
Post a Comment