views:

54

answers:

2

I am trying to create a two view, single controller application as follows: I have two XIB's. Each with the same File's Owner.

As a test, I have placed a UILabel on each XIB. I have connected the File Owner to the UILabel in each XIB. The outlet property is the same.

When I instantiate the nib using loadNibNamed I also set the 'owner' to the instance of File's Owner, e.g.:

nib=[[NSBundle mainBundle] loadNibNamed:@"ONE" owner:OWNER options:nil];
nib=[[NSBundle mainBundle] loadNibNamed:@"TWO" owner:OWNER options:nil];

Now, in OWNER, if I call

[myLabel setText:@"Hello World"];

I see the label update only in nib TWO.

If I create additional UILabels that are unique to each NIB then I can properly update and view them. It seems that I can only have one connection from the property on File's Owner to each NIB.

Any ideas?

A: 

an IBOutlet can only point to one object. You will need two of every IBOutlet you want to use.

Jesse Naugher
A: 

What you want is an IBOutletCollection. That allows you to assign a property to more than one nib element, and talk about the entire group all at once.

Dan Ray
Looks good but it's 4.0 only. I'm really surprised with the MVC nature of Interface Builder that this has not been easily doable another way. Thanks for the feedback however!
Cliff