|
|
1.1 ! root 1: /* Author.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: * This simple Enterprise Object only takes care of the archiving ! 8: * functions. Note that you can add the accessor methods, and other ! 9: * specific functionality as well. ! 10: ! 11: * ! 12: * Written by: Dan Willhite, NeXT Engineering ! 13: */ ! 14: ! 15: #import "Author.h" ! 16: ! 17: @implementation Author ! 18: ! 19: - init ! 20: { ! 21: [super init]; ! 22: return self; ! 23: } ! 24: ! 25: - free ! 26: { ! 27: [authorID autorelease]; ! 28: [firstname autorelease]; ! 29: [lastname autorelease]; ! 30: [address autorelease]; ! 31: [city autorelease]; ! 32: [state autorelease]; ! 33: [zip autorelease]; ! 34: [phone autorelease]; ! 35: ! 36: return [super free]; ! 37: } ! 38: ! 39: ! 40: - (NSString *)id { return [NSString stringWithFormat:@"%X", self]; } ! 41: ! 42: - write:(NXTypedStream *)stream; ! 43: { ! 44: [super write:stream]; ! 45: ! 46: NXWriteNSObject(stream, authorID); ! 47: NXWriteNSObject(stream, firstname); ! 48: NXWriteNSObject(stream, lastname); ! 49: NXWriteNSObject(stream, address); ! 50: NXWriteNSObject(stream, city); ! 51: NXWriteNSObject(stream, state); ! 52: NXWriteNSObject(stream, zip); ! 53: NXWriteNSObject(stream, phone); ! 54: NXWriteTypes(stream, "i", &contract); ! 55: return self; ! 56: } ! 57: ! 58: - read:(NXTypedStream *)stream; ! 59: { ! 60: [super read:stream]; ! 61: ! 62: authorID = [(NSString *)NXReadNSObject(stream) retain]; ! 63: firstname = [(NSString *)NXReadNSObject(stream) retain]; ! 64: lastname = [(NSString *)NXReadNSObject(stream) retain]; ! 65: address = [(NSString *)NXReadNSObject(stream) retain]; ! 66: city = [(NSString *)NXReadNSObject(stream) retain]; ! 67: state = [(NSString *)NXReadNSObject(stream) retain]; ! 68: zip = [(NSString *)NXReadNSObject(stream) retain]; ! 69: phone = [(NSString *)NXReadNSObject(stream) retain]; ! 70: NXReadTypes(stream, "i", &contract); ! 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: return string; ! 91: } ! 92: ! 93: ! 94: ! 95: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.