Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use something like an IBOutlet array?

I have a top list view in my current iPhone app, that's populated by code. I've assembled the view using Interface Builder, so it contains lot of UILabels.

Obviously I wouldn't like to have name1, name2, etc. outlets in my class, but prefer a name[10] array.

Is it possible to do so, and connect each item to the appropriate label (or any other interface builder like view)?

like image 851
shinjin Avatar asked Nov 29 '22 20:11

shinjin


1 Answers

You can of course do this with interface builder, the keyword is IBOutletCollection. What it does is basically an NSArray out of multiple interface builder outlets.

IBOutletCollection(UILabel) NSArray *myLabels;

So the next thing would be connecting your labels in interface builder and then you can use the array to access all labels at runtime.

like image 174
JustSid Avatar answered Dec 01 '22 09:12

JustSid