NSUserDefaults are reset (possible duplicate rdar://10535951)

Originator:mike
Number:rdar://17813085 Date Originated:25-Jul-2014
Status:Open Resolved:YES
Product:iOS Product Version:7.1.2
Classification:Data Loss Reproducible:Always
 
I have an app that responds to significant change notifications. When I start and use the app I save some information to the NSUserDefaults. After the phone reboots my app wakes up because iOS provides a significant change notification.

When my app wakes up I make sure that nothing touches NSUserDefaults unless protected data is available. However, something still creates a fresh set of empty defaults. Those defaults hang around in memory.

If I then unlock my phone and open the app the blank set of defaults are synchronized and all of my data is gone.

Notes:
-If I unlock the phone, but do not start the app and examine the preferences file everything is still there.
-If I unlock my phone, then force quit my app, and then open it everything is fine.

Comments

FYI This has been resolved by Apple. The did 2 things.

  1. Apps no longer get a significant location change update just because the phone restarts
  2. They put in protections to prevent NSUserDefaults from getting wiped.

I've verified that I can't repro this in iOS 8

I don't see a way to attach anything here on Open Radar, but I already did all of that in actual Radar.

Create a small project that demonstrates this and attach to the bug Verify wether it happens with the latest seed


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!