Graphics Programs Reference
In-Depth Information
View Controller Subclasses and Templates
In this exercise, you created a
UIViewController
subclass using the
NSObject
tem-
plate and an empty XIB file. This is useful for learning how the XIB file works. However,
in practice, you typically let
Xcode
do the grunt work and use the
UIViewController
subclass template.
Over the course of this topic, you will create a lot of view controllers. To save on time and
potential errors, you'll use the
UIViewController
template when a view controller
will have a XIB file. When you create a view controller subclass with a XIB template, the
XIB's
File's Owner
is already set to the class of that view controller. It also has an instance
of
UIView
already hooked up to the
File's Owner
's
view
outlet.
There is a drawback, however, to using the view controller template: there is a lot of code
written in the implementation file. It becomes difficult to see what's going on with all of
this extra junk in the file. Therefore, whenever you create a view controller using this tem-
plate, the first thing we'll ask you to do is delete all of the code in the implementation file
between the
@implementation
and
@end
directives.