I don't think NSKeyedArchiver is your problem, since it doesn't know about arrays or anything. Perhaps you need to implement the NSCoding protocol on each subclass?
Edit:
Not sure how you're using your NSKeyedArchiver, but this is how you should use it:
NSMutableData *data = [NSMutableData new];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:array forKey:@"array"];
[data writeToFile:filename attomically:YES];
[archiver release];
[data release];
And to read it in later:
NSData *data = [[NSData alloc] initWithContentsOfFile:filename];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
array = [[unarchiver objectForKey:@"array"] retain];
[unarchiver release];
[data release];
This assumes that array
is some type of NSObject
, including NSArray
, NSSet
, NSDictionary
, etc, or any of their mutable equivalents.