Replace a character on String swift

Solution:

 The below function is used to replace the particular character with another character.
If you want to replace in a particular range then use the range function to replace the characters.

Code:
let str = "This is my string"

let newString = str.replacingOccurrences(of: " ", with: "+", options: .literal, range: nil)

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift