Mercenario
Mercenario

Reputation: 45

Using Text field in Swift

I have a text field and button to search on XIB.

For the variable return for me (house%20of%20sun)

Upvotes: 0

Views: 157

Answers (1)

Fred Faust
Fred Faust

Reputation: 6790

It's pretty straightforward:

var myString = "house of sun"

var myNewString = myString.stringByReplacingOccurrencesOfString(" ", withString: "%20", options: NSStringCompareOptions.LiteralSearch, range: nil)

Where var would be:

yourTextFieldName.text

Upvotes: 1

Related Questions