Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Practical efficient usage of IBOutletColletion

How does look the practical usage of IBOutletCollection? Unfortunately Apple documentation mentions it briefly without giving an wider idea of usage. OK, it maintains one-to-many relation with IB, but how to access and use particular objects efficiently? With TagName? How to ensure the order of objects?

like image 287
juckobee Avatar asked Sep 03 '10 12:09

juckobee


1 Answers

I've recently used this to easily initialize a grid of labels. I have a n by n matrix of labels on a view, and reference each one individually (via an IBOutlet) in order to display relevant data. However when the view first loads I wanted to control the default text that displayed in all the labels. Initially i wanted a dash to display, but since this is for a client I wanted it to be easy to change. The view contents have and continue to change over time, per client requests.

Instead of writing N line of code, I created an IBOutletCollection and accomplished the same results in 4 (@property, @synthesize, and for loop). YMMV but I found it very useful in this situation.

like image 95
logancautrell Avatar answered Oct 03 '22 07:10

logancautrell