View Controller Subclasses and Templates

In this exercise, you were asked to create a UIViewController subclass by using the NSObject template and an empty XIB file that you configured for the view controller. 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.

Throughout the rest of this book, you will create a lot of view controllers. To save on time and potential errors, we will instruct you to use the UIViewController template when that 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 that has been hooked up to the File's Owner’s view outlet.

There is a drawback to using the view controller templates: there is a lot of code written in the implementation file. It becomes difficult to explain where to type the code with all of this extra junk in the file. Therefore, when you create a view controller using these templates, we will instruct you to delete all of the code in the implementation file between the @implementation and @end directives. We’ll tell you this each time you create a file, so you don’t have to remember this, but consider this a heads-up.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.227.9