     public struct URLSerializer: TokenSerializer {
         public static func serialize(token: Token) -> String? {
             let url = urlForToken(name: token.name, issuer: token.issuer, factor: token.core.factor, algorithm: token.core.algorithm, digits: token.core.digits)
-            return url.absoluteString
+            return url?.absoluteString
         }
 
         public static func deserialize(string: String, secret: NSData? = nil) -> Token? {
-            if let url = NSURL.URLWithString(string) {
+            if let url = NSURL(string: string) {
                 return tokenFromURL(url, secret: secret)
             }
             return nil

    return nil
}

private func urlForToken(#name: String, #issuer: String, #factor: Generator.Factor, #algorithm: Generator.Algorithm, #digits: Int) -> NSURL {
    let urlComponents = NSURLComponents()
    urlComponents.scheme = kOTPAuthScheme
    urlComponents.path = "/" + name

    urlComponents.queryItems = [
        NSURLQueryItem(name:kQueryAlgorithmKey, value:stringForAlgorithm(algorithm)),
        NSURLQueryItem(name:kQueryDigitsKey, value:String(digits)),
        NSURLQueryItem(name:kQueryIssuerKey, value:issuer)

    switch factor {
    case .Timer(let period):
        urlComponents.host = FactorTimerString
        queryItems.append(NSURLQueryItem(name:kQueryPeriodKey, value:String(Int(period))))
    case .Counter(let counter):
        urlComponents.host = FactorCounterString
        queryItems.append(NSURLQueryItem(name:kQueryCounterKey, value:String(counter)))
    }

    urlComponents.queryItems = queryItems

    return urlComponents.URL
}
