Check out example codes for "swift url encode string". It will help you in understanding the concepts better.

Code Example 1

let originalString = "test/test"
let escapedString = originalString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
print(escapedString!)

Code Example 2

var urlString = originalString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

Learn ReactJs, React Native from akashmittal.com