title: How to use NSSecureCoding with id objects
body: <p>I'm creating a linked list and using containers to group the object, next, and previous properties. Like Foundation collections, I'd like it to implement <code>NSSecureCoding</code>. Here's the declaration:</p>
  
  <pre><code>@interface ListContainer : NSObject &lt;NSCopying, NSSecureCoding&gt;
  
  @property (readonly, nonatomic) id object;
  @property (nonatomic) ListContainer * next;
  @property (nonatomic) ListContainer * previous;
  
  @end
  </code></pre>
  
  <p>When implementing the <code>- initWithCoder:</code> method it hit me that I don't know what class to use for the object:</p>
  
  <pre><code>- (instancetype)initWithCoder:(NSCoder *)aDecoder
  {
      self = [super init];
  
      if (self) {
  
          _object = [aDecoder decodeObjectOfClass:&lt;#(__unsafe_unretained Class)#&gt; forKey:@"object"];
  
          BOOL nextIsNil = [aDecoder decodeBoolForKey:@"nextIsNil"];
  
          if (!nextIsNil) {
  
              // Decode next
              _next = [aDecoder decodeObjectOfClass:[ListContainer class] forKey:@"next"];
  
              if (_next == nil) {
                  return nil;
              }
  
              // Link the nodes manually to prevent infinite recursion
              self.next.previous = self;
          }
      }
  
      return self;
  }
  </code></pre>
  
  <p>Should I use <code>-decodeObjectForKey:</code> instead? Is it still secure coding?</p>