Skip to content

Instantly share code, notes, and snippets.

@nathankrishnan
Last active April 9, 2017 18:07
Show Gist options
  • Save nathankrishnan/d4d8fb3e2659bc7f69b258847ef95588 to your computer and use it in GitHub Desktop.
Save nathankrishnan/d4d8fb3e2659bc7f69b258847ef95588 to your computer and use it in GitHub Desktop.
Using a set to store malicious domains
var badDomains: Set<String> = ["badguys.com", "drevil.me", "virus.io"]
let websiteToLoad = NSURL(string: "http://virus.io")
if let validDomain = websiteToLoad?.host {
if badDomains.contains(validDomain) {
print("This website is known to be malicious!")
} else {
print("This website doesn't exist in our dossier. Let's proceed.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment