Testing URLs

You can test whether a URL service is available. If the UIApplication’s canOpenURL: method returns YES, you are guaranteed that openURL: can launch another application to open that URL:

if ([[UIApplication sharedApplication] canOpenURL:aURL])     [[UIApplication sharedApplication] openURL:aURL];

You are not guaranteed that the URL is valid—only that its scheme is registered properly to an existing application.

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.