Here is a piece of code where from the array of items is taken from 1 to 3 elements (there are 21 of them). I need to make sure that once you click on an item it does not disappear, but appear (from those that have already been taken) from 1 to 3 (randomly).
@IBOutlet var items: [UIButton]! @IBAction func itemsHidden(sender: UIButton!) { if items.count > 0 && aiDeciding == false { if moveCount < 3 { sender.hidden = true if let index = items.indexOf(sender) { items.removeAtIndex(index) //вот что я пробовал let numberToInsert = Int(arc4random_uniform(UInt32(3))) for _ in 0..<numberToInsert { let tag = Int(arc4random_uniform(UInt32(items.count))) items[tag].hidden = false items.append(tag) } } } } }
arc4random_uniform(x)and if the value you need has come, then again using random select how many elements you want to appear and show them. In other words, you want to write a lot of business logic. Try to specify the question somehow, if you have something concrete that does not work. - Max Mikheyenko