diff --git a/iOS/src/Main.Platform.swift b/iOS/src/Main.Platform.swift index 9c6073a..9b6b007 100644 --- a/iOS/src/Main.Platform.swift +++ b/iOS/src/Main.Platform.swift @@ -1,9 +1,11 @@ +import Combine import UIKit // MARK: - Ядро-VC extension Main { class Core: UIViewController { + let didSelectButton = PassthroughSubject() var buttons = [UIButton]() override func viewDidLoad() { @@ -13,6 +15,11 @@ extension Main { Main.Section16Buttons.setupCore(self) Main.SectionGrid.setupCore(self) + Main.SectionSelection.setupCore(self) + } + + @objc func selectButton(_ btn: UIButton) { + didSelectButton.send(btn.tag) } } } diff --git a/iOS/src/Main.SectionSelection.swift b/iOS/src/Main.SectionSelection.swift new file mode 100644 index 0000000..8074ecc --- /dev/null +++ b/iOS/src/Main.SectionSelection.swift @@ -0,0 +1,23 @@ +import UIKit + +// MARK: - Протоколы + +protocol MainSectionSelection { } + +// MARK: - Реализация + +extension Main { + enum SectionSelection { + static func setupCore(_ core: Main.Core) { + // Учитываем нажатия кнопок. + for btn in core.buttons { + btn.addTarget(core, action: #selector(Main.Core.selectButton), for: .touchUpInside) + } + + // Выводим номер нажатой кнопки. + didSelectButton + .sink { i in print("ИГР MainSS.setupC didSB: '\(i)'") } + .store(in: &core.subscriptions) + } + } +}