TOC | PREV | NEXT

Problem: Your custom object was a subclass of List - but you want to remove all dependencies on possibly unported code and replace List with NSArray. However, you cannot subclass NSMutableArray and get its functionality because it is an abstract class, not a concrete one. Therefore you need to implement an object which acts like an array, and knows how to unarchive a List.
      
      @interface StoneList:List

Solution: Create a new class which has a cover for the NSMutableArray methods via the NSObject's "- forwardInvocation:(NSInvocation *)invocation" method, the NSMutableArray instance variable, and have your objects subclass BogusList. Still, unarchiving old versions is tricky, here's the StoneList initWithCoder:

      @implementation StoneList:BogusList
      
      + (void) initialize { (void)[StoneList setVersion:100]; }
      - (id)initWithCoder:(NSCoder *)aDecoder
      {
            if ( [aDecoder versionForClassName:@"StoneList"] < 100 ) {
            [self init];       // get our array var
            [super initWithCoderExpectingList:aDecoder];
            [aDecoder decodeValuesOfObjCTypes:"@", &name];
      } else {
            [super initWithCoder:aDecoder];
            [aDecoder decodeValuesOfObjCTypes:"@", &name];
      }

TOC | PREV | NEXT
Match: Format:
Search:
Created by Stone Design's Create on 6/2/1997