Question

I've choosen the "view-based" application template in Xcode. The myProjectViewController.m has the following code:

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

That sounds good. But: The template generated a myProjectViewController.xib file. What I dont get is: How does Xcode connect the ViewController with that nib? Where's the part in the template code that says: "Hey, load that myProjectViewController.xib now!"? I mean... can I just delete that not-wanted nib file without setting anything else up appropriately?

Was it helpful?

Solution

yep you can just delete the nib and implement that method IB connects using the name of the class in the NIb, in IB you actually set a view as the file owner of the view. so when you call initwithnib:"nibfilename" it knows what you are talking about.

The elements are wired up using IBOutlets and IBActions

OTHER TIPS

You may wish to refer to my answer to this question, where I describe the specific files that need to be altered to do completely programmatic generation of your view hierarchy. Also, some of the references linked to in the answers to this question may be of use to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top