Good day. I make a game. It is necessary when passing a level, to turn on the button, according to the standard it is turned off (enable = false). Title buttons 1 through 12 (i.e. 12 buttons). I have a variable that contains information about where the user stopped. I thought that it was possible to write a cycle that would open all past levels (the buttons would become enable = true) That is, i = 1 From i to {number of levels passed} do the button.name buttons (int line (i)) = enable finish

In the process of implementation of problems. Not enough experience to write just a cycle. Please help.

Loop in ViewController Buttons in Main.storyboard

  • show what you have already written - Max Mikheyenko
  • Thanks for answering. I already figured it out myself. - KLASTER
  • either publish your answer or delete the question - Max Mikheyenko
  • Well, I posted - KLASTER

1 answer 1

A piece of code that I could not write.

//это объявлСниС Π½ΡƒΠΆΠ½ΠΎ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ ΠΈΡ… ΠΊΠ»ΠΈΠΊΠ°Π±Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ/Π½Π΅ ΠΊΠ»ΠΈΠΊΠ°Π±Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ @IBOutlet var buttonEnable: [UIButton]! override func viewDidLoad() { //всС ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄Π° уровня Π΄ΠΎ Ρ‚ΠΎΠΏ сцСны Π΄Π΅Π»Π°Π΅ΠΌ ΠΊΠ»ΠΈΠΊΠ°Π±Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ for _ in 1...topScene { let button = buttonEnable.removeFirst() button.isEnabled = true } }