Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.