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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access