File:  [NeXTSTEP 3.3 examples] / Examples / EnterpriseObjects / Archiving / ArchivingNSObject / NSAuthor.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:48 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

/* NSAuthor.m
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 *
 *  
 *
 */


#import "NSAuthor.h"

@implementation NSAuthor

- init
{
    [super init];
    return self;
}

- (void)dealloc
{
    [authorID autorelease];
    [firstname autorelease];
    [lastname autorelease];
    [address autorelease];
    [city autorelease];
    [state autorelease];
    [zip autorelease];
    [phone autorelease];
    
    [super dealloc];
}

- (NSString *)id { return [NSString stringWithFormat:@"%X", self]; }

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [super encodeWithCoder:aCoder];

    [aCoder encodeObject:authorID];
    [aCoder encodeObject:firstname];
    [aCoder encodeObject:lastname];
    [aCoder encodeObject:address];
    [aCoder encodeObject:city];
    [aCoder encodeObject:state];
    [aCoder encodeObject:zip];
    [aCoder encodeObject:phone];

    [aCoder encodeValuesOfObjCTypes:"i", &contract];
    
}

- initWithCoder:(NSCoder *)aDecoder
{
    [super initWithCoder:aDecoder];

    authorID = [[aDecoder decodeObject] retain];
    firstname = [[aDecoder decodeObject] retain];
    lastname = [[aDecoder decodeObject] retain];
    address = [[aDecoder decodeObject] retain];
    city = [[aDecoder decodeObject] retain];
    state = [[aDecoder decodeObject] retain];
    zip = [[aDecoder decodeObject] retain];
    phone = [[aDecoder decodeObject] retain];
    
    [aDecoder decodeValuesOfObjCTypes:"i", &contract];
    

    return self;
}

- (NSString *)description
{
    NSMutableString *string;
    
    string = [NSMutableString stringWithFormat:@"{\n"];
    [string appendFormat:@"\tauthorID = %@\n", authorID];
    [string appendFormat:@"\tfirstname = %@\n", firstname];
    [string appendFormat:@"\tlastname = %@\n", lastname];
    [string appendFormat:@"\taddress = %@\n", address];
    [string appendFormat:@"\tcity = %@\n", city];
    [string appendFormat:@"\tstate = %@\n", state];
    [string appendFormat:@"\tzip = %@\n", zip];
    [string appendFormat:@"\tphone = %@\n", phone];
    [string appendFormat:@"\tcontract = %d\n", contract];
    [string appendFormat:@"}\n", address];

    
    return string;
}
@end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.