Created
January 27, 2016 18:42
-
-
Save masonfmatthews/20e5b18008c7919e0327 to your computer and use it in GitHub Desktop.
Using guard
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
func getCount() -> Int { | |
guard let json = self.json else { return 0 } | |
return json.count | |
} | |
func getAll() -> [Clip] { | |
guard json != nil else { return [] } | |
var clips:[Clip] = [] | |
for result in json! { | |
guard let id = result["id"] as? Int, | |
name = result["name"] as? String, | |
url = result["url"] as? String else {continue} | |
clips.append(Clip(id: id, name: name, url: url)) | |
} | |
return clips | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment