You got a brief description of classes earlier in the chapter, but now we need to show you how to declare and implement classes. In order to have a class in Objective-C, it requires two pieces: the interface and implementation.
The interface is used to define the class, its instance variables, and the methods that will be used in the class. The interface is usually stored in the header file; that's the file with the
.h extension. In this code example, we are creating an interface for
ViewController with a parent class of
UIViewController, and within that
ViewController class, we want an instance method called
showAlert that will return
IBAction. This is everything you will want to add into the interface section; ...