NSKeyedArchiver and NSKeyedUnarchiver with NSMutableArray

前端 未结 4 1113
别那么骄傲
别那么骄傲 2021-02-04 18:05

I\'m hoping this isn\'t something to do with the fact that I\'m using a Mutable array here, but this one is baffling me so it wouldn\'t surprise me if that were the case.

<
4条回答
  •  礼貌的吻别
    2021-02-04 18:52

    It doesn't appear that you're initializing the recordObjects in -initWithCoder:

    Try something like this:

    -(id) initWithCoder: (NSCoder *) decoder {
    
        self = [super init];
    
        if (self){
    
           name    = [decoder decodeObjectForKey: @"recordName"] copy];
           anInt   = [decoder decodeIntForKey:    @"recordInteger"];
           aBool   = [decoder decodeBoolForKey:   @"recordBool"];
         }
    
        return self;
    }
    

    The data is there when you archive it but you're not properly unarchiving it.

提交回复
热议问题