Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get the value of a specific query item within NSURL
extension NSURL {
func getQueryItemValueForKey(key: String) -> String? {
guard let components = NSURLComponents(URL: self, resolvingAgainstBaseURL: false) else {
return nil
}
guard let queryItems = components.queryItems else { return nil }
return queryItems.filter {
$0.name == key
}.first?.value
}
}
@danipralea
Copy link

danipralea commented Dec 23, 2016

very nice. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment