Last active
November 10, 2017 11:52
-
-
Save yabenatti/80052f84adc5e8db9f1ef75c36720284 to your computer and use it in GitHub Desktop.
MiniCursoIFSPSwiftFunctions
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
//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