The NSURL
initializer that takes a String
is failable, and the documentation says:
If the URL string was malformed, returns nil.
Attempting to construct a URL with NSURL(string: "tel://+49 00 00 00 00 00")
returns nil.
stringByAddingPercentEscapesUsingEncoding(_:)
and friends are deprecated in iOS 9 in favour of stringByAddingPercentEncodingWithAllowedCharacters(_:)
, which takes an NSCharacterSet
. Which NSCharacterSet
describes the characters which are valid in a tel:
URL?
None of
URLFragmentAllowedCharacterSet()
URLHostAllowedCharacterSet()
URLPasswordAllowedCharacterSet()
URLPathAllowedCharacterSet()
URLQueryAllowedCharacterSet()
URLUserAllowedCharacterSet()
... seem to be relevant