Skip to main content

Replace whiteSpace with %20 in string Swift 3


//Here is a string containing white space

let strWithSpace = "This is swift coding"

let strWithNoSpace = strWithSpace.replacingOccurrences(of: " ", with: "%20")
print(strWithNoSpace)

OutPut:- This%20is%20swift%20coding


Happy Coding:)

Comments

Post a Comment

Popular posts from this blog

Call phone Number In swift 3

//Here you can make method of calling functionality. func callNumber (yourP honeNumber : String ) { if let phoneCallURL = URL ( string : "tel://\(yourP honeNumber )" ) { let application : UIApplication = UIApplication . shared if ( application . canOpenURL ( phoneCallURL )) { application . open ( phoneCallURL , options : [:], completionHandler : nil ) } } } Happy Coding :)

Create ActionSheet and AlertView in swift 3

let  alertVC:  UIAlertController  = UIAlertController (title:  "Alert" , message:  "YOUR MESSAGE" , preferredStyle: .actiobSheet)    let  okBtn = UIAlertAction. init (title:  "Ok" , style: . default , handler: {  _   in                           // Perform whatever you want                          })     alertVC.addAction(okBtn)     self .present(alertVC, animated:  true , completion:  nil )