ios - Does NSKeyedArchiver overwrite the previous archive value? -


i using following ios app data backup

  • nskeyedarchiver.archiverootobject()
  • nskeyedunarchiver.unarchiveobjectwithfile()

based on apple documentation here -

i curious here potentially silly question - previous archive deleted each time make new save?

question

  • when calling nskeyedarchiver.archiverootobject() new archive overwrite previous archive value?
  • if doesn't overwrite old value need delete old value?

here useful reference on deleting nskeyedarchiver values

nskeyedarchiver not responsible overwrite previous object. convert youobject nsdata , vice versa. because, 'custom object' can't save nsuserdefaults.

additionay, overrite data should this.i.e

 [userdefaults setobject:data forkey:identifier];  [userdefaults synchronize]; 

remove data:

[[nsuserdefaults standarduserdefaults] removeobjectforkey:identifier]; [[nsuserdefaults standarduserdefaults] synchronize]; 

Comments