That's a problem and i cannot find the solution. In my program i try to open Safari with url, and that was ok until the occasion: i tried to link the site with russian host and domain, for example:
let url = "http://карта.рф"
fatal error: unexpectedly found nil while unwrapping an Optional value
You need the character set related to the host
let string = "http://" + "карта.рф".stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())! let url = NSURL(string:string)
If you have to encode also
NSURLComponents and encode the other components separately.
let components = NSURLComponents() components.scheme = "http" components.host = "карта.рф".stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet()) let url = components.URL!