The Complete Tutorial on iOS/iPhone Custom URL Schemes

Note: Since the introduction of custom URL schemes, this post has consistently been the top read content on the blog. Although much is the same, there are a few nuances that have changed. This is a re-write of the original post, updated for the latest iOS and Xcode versions.

One of the coolest features of the iPhone/iOS SDK is an application’s ability to “bind” itself to a custom URL scheme and for that scheme to be used to launch the application from either a browser or from another application.

Continue reading

URL Encoding in Objective-C

The NSString class contains a method stringByAddingPercentEscapesUsingEncoding which returns a URL-encoded string. Problem is, the method seems to provide support for percent escapes on just a few characters.

Below is a category extension to the NSString class that uses the method CFURLCreateStringByAddingPercentEscapes in the CFURL class to handle a more complete set of characters for encoding. By using a category (versus a standalone method in a class) we are essentially adding a new method for encoding to all NSString objects.

Continue reading

Download, Create and Display an Image from URL

This tip will show the steps to download and display an image from a remote resource. This is handy if you need to add an image as a subview, yet, the image is not part of your application bundle.

URL to Remote Image

We start by creating a URL to the remote resource:

Create UIImage from NSData

The next step is to build a UIImage using the data downloaded from the URL, which consists of an NSData object that holds the remote image contents:

Putting it Together

Here’s how to wrap it all together, adding the remote image as a subview to an existing view by creating a UIImageView from the above UIImage: