NSKeyedArchiver and NSKeyedUnarchiver with NSMutableArray

前端 未结 4 1120
别那么骄傲
别那么骄傲 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 19:00

    I was having the same issue when unarchiving a custom object

    self.calTable = [[NSKeyedUnarchiver unarchiveObjectWithFile:calibrationFile] objectForKey:@"calTable"];
    

    Based on Rob's answer I changed to

    self.calTable = [[[NSKeyedUnarchiver unarchiveObjectWithFile:calibrationFile] mutableCopy] objectForKey:@"calTable"];
    

    and it fixed all errors.

提交回复
热议问题