Home / IOS Development / IBOutlet collection data type? : iOSProgramming

IBOutlet collection data type? : iOSProgramming



Sorry if the formatting is bad, I do not often add any code to reddit. Basically, I have created a collection of IBOutlets called calcButtonsOutlet. I then did the function fRoundCorners() to be able to go through all the outlets in calcButtonsOutlet and use them a corner radius. As I have learned quickly, whatever function I have done, I have tried to make them universal by going through arguments and parameter labels. In this case, I’m trying to create a function that will:

  1. check to see if the data sent through is of a collection type.

  2. if it is a collection, run a loop

  3. Otherwise, if it is NOT a collection, just use the corner radius of the specific instance.

My thinking was to create a function to check the type of data that is submitted, if it is an array / collection type, go on to step 2 / next it inside a corner radius function. I’m stuck trying to figure out how to address the type of data I want the feature to check for in the event of a collection of IBOutlets.

Thanks in advance.

class ViewController: UIViewController {
    u/IBOutlet var calcButtonsOutlet: [UIButton]!
    u/IBOutlet var buttonNine: UIButton!
    u/IBOutlet var resultOutlet: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        fRoundCorners()
    }

    func fRoundCorners() {
        for button in calcButtonsOutlet {
            button.layer.cornerRadius = 15
        }
    }

}

Source link