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

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.