Create an enum with success and error cases, each with associated values:

enum URLResult {
    case Success(NSURL)
    case Error(String)
}

The example function returns the url result enum type. If the url was successfully created, pass the url with the associated value. Otherwise, pass an error string with the associated value.

func createURL() -> URLResult {
    if let url = NSURL(string: "http://www.apple.com/") {
        return .Success(url)
    } else {
        return .Error("The URL string is malformed or nil.")
    }
}

Then switch on the return value of the function call:

switch createURL() {
    case let .Success(url): println(url)
    case let .Error(error): println(error)
}