O'Reilly logo

Learning Objective-C by Developing iPhone Games by Amy M. Booker, Joseph D. Walters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming with Objective-C

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.

@interface

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required