Graphics Programs Reference
In-Depth Information
A subclass of
NSObject
can override this method to return something that better de-
scribes an instance of that subclass. For example,
NSString
overrides
description
to return the string itself.
NSArray
overrides
description
to return the description of
every object in the array.
Creating an NSObject subclass
In this section, you're going to create a subclass of
NSObject
named
BNRItem
. An in-
stance of the
BNRItem
class will represent an item that a person owns in the real world.
To create a new class in
Xcode
, choose
File
→
New
→
New File...
. In the lefthand table
of the panel that appears, select
Cocoa
from the
Mac OS X
section. Then select
Objective-
C class
from the upper panel and hit
Next
(
Figure 2.9
)
.
Figure 2.9 Creating a class
On the next panel, name this new class
BNRItem
. Select
NSObject
as the superclass and
click
Next
, as shown in
Figure 2.10
.