Last active
September 25, 2015 10:41
-
-
Save odrobnik/680d16ea22025d70fb86 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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