Last active
August 25, 2016 09:21
-
-
Save nubbel/aba4e6ac785c8606caad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension NSURL : StringLiteralConvertible { | |
class func convertFromStringLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
} | |
var url: NSURL = "http://google.com" | |
url.host // => google.com | |
url.scheme // => http | |
func hostFromURL(URL: NSURL) -> String { | |
return URL.host | |
} | |
// String literal is automatically converted to NSURL | |
hostFromURL("http://google.com") // => google.com | |
// wow, even that works | |
"http://google.com".host // => google.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment