1

I recently changed a bit of code using Archiver to replace the object being decoded with another if the object was in a shared list. My app is using ARC.

- (id)awakeAfterUsingCoder:(NSCoder*)decoder {
    Player* player = [[Team getCurrentTeam] getPlayerWithId: self.id];
    // If the player is in the current team then use that instance instead of this one.
    if (player !=  nil) {
        return player;
    } else {
        return self;
    }
}

The code worked great until I added the awakeAfterUsingCoder. Now I am getting malloc: error for object 0x7567430: pointer being freed was not allocated. It would appear that the object being replaced is being released but it was never retained? Since I'm using ARC I'm not sure what I might do to resolve this.

Ilanchezhian
  • 17,426
  • 1
  • 53
  • 55
velohomme
  • 136
  • 2
  • 9

0 Answers0