Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Last active September 25, 2015 10:41
Show Gist options
  • Save odrobnik/680d16ea22025d70fb86 to your computer and use it in GitHub Desktop.
Save odrobnik/680d16ea22025d70fb86 to your computer and use it in GitHub Desktop.
import Foundation
func checkIt(nameString: String, dictionary: [String: String]) -> Bool
{
let namePieces = nameString.componentsSeparatedByString("/")
guard namePieces.count > 2,
let urlString = dictionary["url"],
url = NSURL(string: urlString),
_ = dictionary["itag"],
type = dictionary["type"]
where type.containsString("video/mp4")
else
{
return false
}
url // outputs the correct URL in playground
return true
}
let dict = ["url": "http://domain/file", "itag": "bla", "type": "video/mp4"]
checkIt("/something/bla.mp4", dictionary: dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment