Pegah
Pegah

Reputation: 682

The storyboard is automatically copied to the new project

I have a project in Xcode, lets name it A, in which I have a story board and several views. I only need part of project A. Hence, I made a new project, B, and made a new UIViewController, with xib, and copied the two UIViews from project A to B. It looks like this now, where RPM Display and Speed Display are copied (by dragging from xib) from A to B.

enter image description here

AnalogDisplayContainer belongs to the class PD_AnalogDisplayContainer, and we have two outlets in class PD_AnalogDisplayContainer:

@property (nonatomic,assign) IBOutlet PD_AnalogDisplay* speedDisplay;
@property (nonatomic,assign) IBOutlet PD_AnalogDisplay* rpmDisplay;

which are connected to the respective views in xib. (We have exactly the same code in project A.) These UIViews have some UILabels as well, which are automatically copied in project B, and I need them as well. You see them here:

enter image description here

Up to here, the description of what I did. Now, the problem: I have three outlets in class PD_AnalogDisplay.

@property (nonatomic, assign) IBOutlet UILabel* unitLabel;
@property (nonatomic, assign) IBOutlet UILabel* digitalIntegerValue;
@property (nonatomic, assign) IBOutlet UILabel* digitalFloatValue;

However, so strangely, when I click on the small point beside these outlets, it shows me the connections to story board,

enter image description here

and when I click on the connection, I see the whole storyboard and views from project A.

enter image description here

In addition, these connections are not shown when I click on xib.

enter image description here

I searched in project B, there is no storyboard, or all these things I see in the previous picture, in form of code. So I don't know where it all come from. And I get the run time error: loaded the "RPMViewController" nib but the view outlet was not set.

Upvotes: 0

Views: 125

Answers (1)

Preetam Jadakar
Preetam Jadakar

Reputation: 4561

Yes, it brings previous reference wherever you copy it. It is happening because the class name is same in project A and B. Create class name in project B other than class name in project A or slightly change variable name.

Assign that class to your xib file. You must recreate the IBOutletes from xib file. Just copy the interface components not the code in .h file.

Observations:

  • When I move project A to another location makes trick, reference destroyes.

Upvotes: 1

Related Questions