Interface builder :
- StoryBoard
- easy way, less flexible, hard to do programmatically
- XIB
- create a view only, easy to do programmatically
What is XIB :
- XIB stands for XML Interface Builder
- Object editor, you create and configure objects like buttons and controllers, save them into archive called XIB
What is NIB :
- When you build app, the XIB file is compiled into NIB file for efficiency
- Then NIB file is copied into app’s bundle
- Bundle, a directory contains app’s executable and any resources
Connections:
- Let one object know where another object is in memory, so that two objects can communicate
- More precisely, often between controller and view communication
- outlets, as property, no need to know who is sender
- actions, as implementation, sometimes needed to know who is sender, so that you can perform desired action
Connect your controller to appDelegate :
- To get your interface on screen, you have to connect your view controller to app’s controller: appDelegate
- That means, you need to make your controller as root controller of this window.
- appDelegate, manages a single top-level UIWindow for the application.
Initializers:
- begins with word init, name convention only
- designated initializer, no matter how many init methods are, one method is chosen as designated, it makes sure that every instance variable of an object is valid.
Controller Initializer :
When an instance of controller is created, it is sent the message initWithNibName:bundle
Instancetype :
- Why not return specific type ? all about polymorphism
- Deal with the problem if the class was subclassed but sending this init message to subclass :(
- Return the type of the caller
Reference
- Stanford iOS 7 development
- Mac Developer Library
- Big Nerd Ranch