O'Reilly logo

Objective-C Programming: The Big Nerd Ranch Guide by Mikey Ward, Aaron Hillegass

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

18 Your First Class

So far, you have only used classes created by Apple. Now you get to write your own class. Remember that a class describes objects in two ways: instance variables within each instance of the class and methods implemented by the class.

You are going to write a BNRPerson class, which will be similar to the struct Person you wrote in Chapter 11. This class, like all Objective-C classes, will be defined in two files:

  • BNRPerson.h is the class’s header and will contain the declarations of instance variables and methods.

  • BNRPerson.m is the implementation file. This is where you write out the code for, or implement, each method.

First, create a new project: a Foundation Command Line Tool named BMITime ...

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