One Quickie


Supporting NSKeyedArchiving in your objects (NSCoder->General)
They should conform to the NSCoding protocol.
- (void) encodeWithCoder: (NSCoder *) coder
{
    [coder encodeInt: x  forKey: @"x"];
    [coder encodeInt: y  forKey: @"y"];
    [coder encodeObject: color1  forKey: @"color1"];
    [coder encodeObject: color2  forKey: @"color2"];
    [coder encodeInt: direction  forKey: @"direction"];

} // encodeWithCoder


- (id) initWithCoder: (NSCoder *) coder
{
    if (self = [super init]) {
        x = [coder decodeIntForKey: @"x"];
        y = [coder decodeIntForKey: @"y"];
        color1 = [coder decodeObjectForKey: @"color1"];
        color2 = [coder decodeObjectForKey: @"color2"];
        direction = [coder decodeIntForKey: @"direction"];
    }

    return (self);

} // initWithCoder



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com