Here's the thing about .xib and storyboards

Originally, there was just programmatic declaration and instantiation of all objects, including UIElements. This is fine for things with a few properties. But a single UIElement, could reasonably have many, many properties that need definition, so setting just a simple button looks like this:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.opaque = NO; button.contentMode = UIViewContentModeScaleToFill; button.frame = CGRectMake(142, 518, 30, 30); button.titleLabel.text = @"hello"; button.backgroundColor = [UIColor whiteColor]; [button addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];

It doesn't take long until either the tedium of that or the cluttered code make you want to simply pass a list of properties to a single method that creates the object. and then hide the list somewhere.

apparently Apple felt the same way. Enter .nib/.xib

a .xib is nothing more than a list of properties that get converted (I presume) to code. Other than properties, it basically only does one code-based thing, which is the instantiation of the objects themselves. (you can look at it by ctrl-clicking the .xib in the left pane navigator and selecting "open as"->"Source Code")

So then, alloc/initWithNib: is just telling the compiler to allocate the VC and instantiate it with a method that knows how to read the .xib file and turn that into a long list of instantiation and property setting methods.

Pretty Cool.

What you are looking at in Interface Builder is simply a visual editing tool of all that text.

When you really understand this, then so much of what you are (or at least I am) doing makes much more sense.

<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7h7-sq-Pk5"> <rect key="frame" x="142" y="518" width="36" height="30"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" title="Send"> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> </state> <connections> <action selector="share:" destination="-1" eventType="touchUpInside" id="Ed1-05-Vqm"/> </connections>

What does this mean for passing pointers of UIElements?