Skip to content

Instantly share code, notes, and snippets.

@yabenatti
Last active November 10, 2017 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yabenatti/80052f84adc5e8db9f1ef75c36720284 to your computer and use it in GitHub Desktop.
Save yabenatti/80052f84adc5e8db9f1ef75c36720284 to your computer and use it in GitHub Desktop.
MiniCursoIFSPSwiftFunctions
//Regular function
func fillScreen() {
if let animal = self.selectedAnimal {
self.animalImageView.image = UIImage.init(named: animal.image)
self.animalNameLabel.text = animal.name.uppercased()
}
}
//Function with alias on parameter
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
//Class function
class AnimalsFactory {
class func createAnimals() -> [Animal] {
var animalsArray: [Animal] = []
for (name, image) in animalsAndImages {
let animal = Animal(name: name, image: image)
animalsArray.append(animal)
}
return animalsArray
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment