tags:

views:

90

answers:

2

I'm using the iPhone SDK to build a simple application. I've created a brand new class which has a single variable. I need to make 5 instances of that class, which I have no trouble doing. I can create those instances and also set the variables without issue. What i do need to know is this:

How do I link each of the 5 different instances of the variable to different and specific UILabels?

Would I be better to create a method that dynamically creates and positions the labels?

Thanks for your help in advance, I'm now to this iphone programming thing. I'm serious about learning fast though so I have posted a bounty on this question here :

http://www.askearn.com/Responses.aspx?QuestionID=6542613f-7be8-4bb3-a950-aac218d47711

+1  A: 

I'm assuming that you have a single view and associated view controller that contain the 5 UILabels? If so, set the text property of each label in the viewDidLoad method of your UIViewController

With regards to the second part of your question about positioning the labels, that's up to you to decide the best way to set them. I would recommend starting out with Interface Builder first and only resorting to positioning them in code if you need to.

kubi
A: 

If you want to link UILabels with Interface Builder you need to set a few things.

IBOutlet UILabel *label;
@property (retain) IBOutlet UILabel *label;

Then you should be able to link the pointer *label to a specific UILabel inside Interface Builder.

Check out Apple's guide for more a more in depth tutorial. It walks you through setting up Interface Builder.

Pyro2927
You don't need/want 'IBOutlet' before both the ivar *and* the Property declaration. Though at first  favored putting it before the ivar it seems as though they, and most others, are now putting it in the Property declaration.
Meltemi
True. Doesn't hurt though.
Pyro2927