|
|
1.1 ! root 1: /* NSAuthor.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: * ! 9: */ ! 10: ! 11: ! 12: #import "NSAuthor.h" ! 13: ! 14: @implementation NSAuthor ! 15: ! 16: - init ! 17: { ! 18: [super init]; ! 19: return self; ! 20: } ! 21: ! 22: - (void)dealloc ! 23: { ! 24: [authorID autorelease]; ! 25: [firstname autorelease]; ! 26: [lastname autorelease]; ! 27: [address autorelease]; ! 28: [city autorelease]; ! 29: [state autorelease]; ! 30: [zip autorelease]; ! 31: [phone autorelease]; ! 32: ! 33: [super dealloc]; ! 34: } ! 35: ! 36: - (NSString *)id { return [NSString stringWithFormat:@"%X", self]; } ! 37: ! 38: - (void)encodeWithCoder:(NSCoder *)aCoder ! 39: { ! 40: [super encodeWithCoder:aCoder]; ! 41: ! 42: [aCoder encodeObject:authorID]; ! 43: [aCoder encodeObject:firstname]; ! 44: [aCoder encodeObject:lastname]; ! 45: [aCoder encodeObject:address]; ! 46: [aCoder encodeObject:city]; ! 47: [aCoder encodeObject:state]; ! 48: [aCoder encodeObject:zip]; ! 49: [aCoder encodeObject:phone]; ! 50: ! 51: [aCoder encodeValuesOfObjCTypes:"i", &contract]; ! 52: ! 53: } ! 54: ! 55: - initWithCoder:(NSCoder *)aDecoder ! 56: { ! 57: [super initWithCoder:aDecoder]; ! 58: ! 59: authorID = [[aDecoder decodeObject] retain]; ! 60: firstname = [[aDecoder decodeObject] retain]; ! 61: lastname = [[aDecoder decodeObject] retain]; ! 62: address = [[aDecoder decodeObject] retain]; ! 63: city = [[aDecoder decodeObject] retain]; ! 64: state = [[aDecoder decodeObject] retain]; ! 65: zip = [[aDecoder decodeObject] retain]; ! 66: phone = [[aDecoder decodeObject] retain]; ! 67: ! 68: [aDecoder decodeValuesOfObjCTypes:"i", &contract]; ! 69: ! 70: ! 71: return self; ! 72: } ! 73: ! 74: - (NSString *)description ! 75: { ! 76: NSMutableString *string; ! 77: ! 78: string = [NSMutableString stringWithFormat:@"{\n"]; ! 79: [string appendFormat:@"\tauthorID = %@\n", authorID]; ! 80: [string appendFormat:@"\tfirstname = %@\n", firstname]; ! 81: [string appendFormat:@"\tlastname = %@\n", lastname]; ! 82: [string appendFormat:@"\taddress = %@\n", address]; ! 83: [string appendFormat:@"\tcity = %@\n", city]; ! 84: [string appendFormat:@"\tstate = %@\n", state]; ! 85: [string appendFormat:@"\tzip = %@\n", zip]; ! 86: [string appendFormat:@"\tphone = %@\n", phone]; ! 87: [string appendFormat:@"\tcontract = %d\n", contract]; ! 88: [string appendFormat:@"}\n", address]; ! 89: ! 90: ! 91: return string; ! 92: } ! 93: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.