-2

Link is not working properly:

let MoovitURL: String = "moovit://nearby?lat=40.758896&lon=-73.985130&title=\(barNameTemplate)&partner_id=<nightout>"

        let escapedString = MoovitURL.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
        UIApplication.shared.openURL(URL(string: escapedString!)!)

Saying:

fatal error: unexpectedly found nil while unwrapping an Optional value
2017-08-14 22:49:35.983585+0300 TestApp[10658:6538686] fatal error: unexpectedly found nil while unwrapping an Optional value

crashing on line:

UIApplication.shared.openURL(URL(string: MoovitURL)!)
RandomGeek
  • 303
  • 5
  • 20

1 Answers1

-1

Swift doesn't think your string is an actual URL, so it returned nil. When you tried to force unwrap it (!), it gave an error.

Oliver Ni
  • 2,606
  • 7
  • 29
  • 44