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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift