ios - How to delete a bunch of NSData in NSUserDefault -
i stored setting peripheral connected ios device, want add button user delete peripheral, means must delete setting related peripheral.
the store simple using nsdata:
nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; nsdata *encodedobject = [nskeyedarchiver archiveddatawithrootobject:self.appdelegate.defaultbtserver.selectperipheralinfo]; [defaults setobject:encodedobject forkey:self.appdelegate.defaultbtserver.selectperipheralinfo.uuid]; [defaults synchronize];
but how delete setting related selectperipheralinfo.uuid? found
nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; [defaults removeobjectforkey:application.defaultbtserver.selectperipheralinfo.uuid];
cannot work.
it looks might not using same key add , remove data. add, used:
self.appdelegate.defaultbtserver.selectperipheralinfo.uuid
but remove data used:
application.defaultbtserver.selectperipheralinfo.uuid
if values of expressions aren't same, won't able remove data added because, obviously, key wrong. so, check that.
also, make sure call [defaults synchronize]
after removing update defaults in storage.
Comments
Post a Comment