How do you use NSCoder to encode and decode custom types?
For example, how would you use NSCoder with an instance of "STATE" where:
typedef enum { ON, OFF } STATE;
You can treat them as integers as they are implicitly assigned integer values:
- (void) encodeWithCoder: (NSCoder *)coder {
  ...
  [coder encodeInt:type forKey:@"state"];
}
- (id) initWithCoder: (NSCoder *)coder {
  ...
  state = [coder decodeIntForKey:@"state"];
}