My book on iOS interface design, Design Teardowns: Step-by-step iOS interface design walkthroughs is now available!

Working with URLs

It's cumbersome to work with NSURL with all its verbosity. Here's a sweet way to make that all better with Swift.

import Foundation

func +(lhs: NSURL, rhs:String) -> NSURL {  
    return lhs.URLByAppendingPathComponent(rhs)
}

This way you can simply use:

let url = NSURL(string: "http://google.com")!  
url \\ "http://google.com"  
url + "pages" \\ "http://google.com/pages"