How to use NSSecureCoding with id objects

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 NSSecureCoding. Here's the declaration:


    @interface ListContainer : NSObject <NSCopying, NSSecureCoding>
  
    @property (readonly, nonatomic) id object;
    @property (nonatomic) ListContainer * next;
    @property (nonatomic) ListContainer * previous;
  
    @end


When implementing the - initWithCoder: method it hit me that I don't know what class to use for the object:


    - (instancetype)initWithCoder:(NSCoder *)aDecoder
    {
        self = [super init];
      
        if (self) {
          
            _object = [aDecoder decodeObjectOfClass:<#(__unsafe_unretained Class)#> 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;
    }


Should I use -decodeObjectForKey: instead? Is it still secure coding?

How to use NSSecureCoding with id objects
 
 
Q