05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

490<br />

CHAPTER 26 MAC <strong>OS</strong> X DEVELOPMENT: OBJECTIVE-C<br />

- (void)dealloc;<br />

{<br />

[name release];<br />

name = nil;<br />

}<br />

[super dealloc];<br />

- (NSString *)name;<br />

{<br />

return name;<br />

}<br />

- (void)setName:(NSString *)aName;<br />

{<br />

if (name == aName)<br />

return;<br />

}<br />

[name release];<br />

name = [aName retain];<br />

- (NSUInteger)age;<br />

{<br />

return age;<br />

}<br />

- (void)setAge:(NSUInteger)anAge;<br />

{<br />

age = anAge;<br />

}<br />

@end<br />

As with the interface, you start by importing:<br />

#import "BMPerson.h"<br />

If you recall, you imported the Cocoa framework differently:<br />

#import <br />

Why the change in syntax? When importing system frameworks, use the path notation and<br />

the angle brackets. When importing your own headers, use the quote notation.<br />

Incidentally, you don’t have to import Cocoa into this implementation, because the header<br />

has already imported it. Importing a header also imports any headers it has imported. As you can<br />

imagine, that gets complicated quickly, which is why we use #import and not #include.<br />

You open the implementation with the @implementation directive and the name of the class:<br />

@implementation BMPerson<br />

You don’t have to rename the superclass or redeclare the instance variables, so you can<br />

move right into methods.<br />

Class Methods<br />

The methods are opened with the same declaration as in the header:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!