One Quickie


Supporting encoding (NSCoder->General)
- (void) encodeWithCoder: (NSCoder *) aCoder
{
    // [super encodeWithCoder:] if you inherit from a class
    // that supports encoding.  NSObject does not.

    // encoding a C type
    [aCoder encodeValueOfObjCType: @encode(int)
            at: &itemCount];

    // encoding an array of C structs
    int i;
    for (i = 0; i < itemCount; i++) {
        [aCoder encodeValueOfObjCType: @encode(BWRawPathItem)
                at: &items[i]];
    }

    // encoding an object
    [aCoder encodeObject: name];

} // encodeWithCoder



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

webmonster@borkware.com