I think you are missing a URL with UIApplication.sharedApplication().canOpenURL(url), for example, change the code to this:
func verifyUrl (urlString: String?) -> Bool {
if let urlString = urlString {
if let url = NSURL(string: urlString) {
return UIApplication.sharedApplication().canOpenURL(url)
}
}
return false
}
verifyUrl("escola") // false
verifyUrl("http://wwww.google.com") // true
The constructor NSURLdoes not check the URL, do you think, according to Apple :
This method expects that it URLStringwill only contain characters that are allowed in a well-formed URL. All other characters must be properly escaped. Any skipped percent characters are interpreted using UTF-8 encoding
, .