One Quickie
Supporting decoding (NSCoder->General)
- (id) initWithCoder: (NSCoder *) aDecoder
{
if (self = [super init]) {
// or else [super initWithCoder: aDecoder] if your superclass
// supports it. NSObject does not.
// decoding a C type
[aDecoder decodeValueOfObjCType: @encode(int)
at: &itemCount];
// decoding an array of C structs
if (items != NULL) {
free (items);
}
items = malloc (sizeof(BWRawPathItem) * itemCount);
int i;
for (i = 0; i < itemCount; i++) {
[aDecoder decodeValueOfObjCType: @encode(BWRawPathItem)
at: &items[i]];
}
// decoding an object
name = [aDecoder decodeObject];
[name retain];
// any other random initializations that don't come from
// the encoder
fooby = -1;
}
return (self);
} // initWithCoder