What is an IBOutletCollection in iOS??

When we try to create a new IBOutlet or new IBAction, a third option shows up named IBOutletCollection. I always wondered what it is, but never got a chance to check that out. If you already know what it is, then please skip this article.

Image for post
Image for post
@IBOutlet var starButtons: [UIButton]!
Image for post
Image for post
star rating view
Image for post
Image for post
storyboard implementation
@IBOutlet var starButtons: [UIButton]!
Image for post
Image for post
Image for post
Image for post
@IBAction func buttonTapped(_ sender: UIButton) {print(“Rated \(sender.tag) stars.”)for button in starButtons {if button.tag <= sender.tag {button.setImage(UIImage.init(named: “star_selected”), for: .normal)} else {button.setImage(UIImage.init(named: “star_normal”), for: .normal)}}}
Image for post
Image for post
working gif

If you enjoyed reading this post, please share and give some clapps so others can find it 👏👏👏👏👏 !!!!

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store