I have an NSURL being returned to me as something like
tel:555-555-5555
I can recognize it as a telephone by identifying the NSURL's scheme as "tel" using
let url = NSURL(string: "tel:555-555-5555")
if url.scheme == "tel" {
// it's a telephone number
}
But I can't find a command to get the actual phone number component. The phone numbers can come back much more messy than the example I gave, so I thought it would be much safer to ask if there was a way to get the phone number component directly instead of saving as string and clipping out the scheme.
Use resourceSpecifier:
let url = NSURL(string: "tel:555-555-5555")!
if url.scheme == "tel" {
let number = url.resourceSpecifier
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With