|
|
1.1 ! root 1: /* Person.m ! 2: * ! 3: * You may freely copy, distribute, and reuse the code in this example. ! 4: * NeXT disclaims any warranty of any kind, expressed or implied, as to its ! 5: * fitness for any particular use. ! 6: * ! 7: * ! 8: * A simple class describing a person object. ! 9: * ! 10: * ! 11: *------------------------------------------------------------------------*/ ! 12: ! 13: #import <appkit/Application.h> ! 14: #import "Person.h" ! 15: ! 16: ! 17: ! 18: ! 19: ! 20: @implementation Person ! 21: ! 22: /*-------------------------------------------------------------------------- ! 23: * Initialization and Deallocation ! 24: *------------------------------------------------------------------------*/ ! 25: - init ! 26: { ! 27: [super init]; ! 28: return self; ! 29: } ! 30: ! 31: ! 32: - (void) dealloc ! 33: { ! 34: [firstname autorelease]; ! 35: [lastname autorelease]; ! 36: [city autorelease]; ! 37: [super dealloc]; ! 38: } ! 39: ! 40: ! 41: /*-------------------------------------------------------------------------- ! 42: * Accessors ! 43: *------------------------------------------------------------------------*/ ! 44: - lastname ! 45: { ! 46: return lastname; ! 47: } ! 48: ! 49: ! 50: - firstname ! 51: { ! 52: return firstname; ! 53: } ! 54: ! 55: ! 56: - city ! 57: { ! 58: return city; ! 59: } ! 60: ! 61: ! 62: - (void) setFirstname: (NSString *) aString ! 63: { ! 64: [firstname autorelease]; ! 65: firstname = [aString retain]; ! 66: } ! 67: ! 68: ! 69: - (void) setLastname: (NSString *) aString ! 70: { ! 71: [lastname autorelease]; ! 72: lastname = [aString retain]; ! 73: } ! 74: ! 75: ! 76: - (void) setCity: (NSString *) aString ! 77: { ! 78: [city autorelease]; ! 79: city = [aString retain]; ! 80: } ! 81: ! 82: ! 83: ! 84: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.