0

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

  • For example: i write "house of sun" on text field

    How can i catch this sentence (house of sun) and transform into a variable and put "%20" on the spaces between the words ?

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

1

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.