This file contains hidden or 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
setOfNumbers.isEmpty // returns true or false depending in the set. |
This file contains hidden or 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
setOfNumbers.remove(6) // removes an element | |
setOfNumbers.removeAll() // removeAll() remove all elements |
This file contains hidden or 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
setOfNumbers.count |
This file contains hidden or 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
setOfNumbers.insert(6) |
This file contains hidden or 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
var setOfNumbers = Set<Int>() // you can change 'Int' with hashable type you want to work with. |
This file contains hidden or 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
class ChooseViewController: UIViewController { | |
@IBOutlet weak var sunButton: SpaceCustomButton! | |
@IBOutlet weak var mercuryButton: SpaceCustomButton! | |
@IBOutlet weak var venusButton: SpaceCustomButton! | |
@IBOutlet weak var earthButton: SpaceCustomButton! | |
@IBOutlet weak var moonButton: SpaceCustomButton! | |
@IBOutlet weak var marsButton: SpaceCustomButton! | |
@IBOutlet weak var jupiterButton: SpaceCustomButton! | |
@IBOutlet weak var saturnButton: SpaceCustomButton! |
This file contains hidden or 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
@IBAction func changeButtonDidTapped(_ sender: Any) { | |
let chooseVC = storyboard?.instantiateViewController(identifier: "chooseVC") as! ChooseViewController | |
chooseVC.modalPresentationStyle = .fullScreen | |
chooseVC.delegate = self // This line of code | |
self.present(chooseVC, animated: true, completion: nil) | |
} |
This file contains hidden or 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
var delegate: ChoosePlanetMoonDelegate! |
This file contains hidden or 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
class MainViewController: UIViewController, ChoosePlanetMoonDelegate { | |
@IBOutlet weak var mainPlanetImage: UIImageView! | |
@IBOutlet weak var changeButton: UIButton! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
@IBAction func changeButtonDidTapped(_ sender: Any) { | |
let chooseVC = storyboard?.instantiateViewController(identifier: "chooseVC") as! ChooseViewController |
This file contains hidden or 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
import UIKit | |
protocol ChoosePlanetMoonDelegate { | |
func didChoosePlanetWith(image: UIImage) | |
} |