Cannot convert value of type string to type url in coercion

You can’t cast a string to a URL. Casting simply says “Ok, the thing in this box. It’s not a string, it’s an URL.” If the object can’t double as the other class, the cast fails.

You need to create a URL using a string as input:

let url = URL(string: myString)

Leave a Comment