iOS 10 with XCode 8 GM caused NSUserDefaults to intermittently not work

≯℡__Kan透↙ 提交于 2019-11-29 22:28:30

Yes, this is definitely a reproducible bug.

  • It happens with the GM release of Xcode 8 and iOS 10.
  • It is not the linked question referring to Swift.
  • It is not the linked question referring to beta versions of the Simulator.

The bug happens on devices and on the Simulator. It is intermittent: saving will work six times and then fail. Unlike you, I did not get the "failed to write key" message.

The bug also occurs when operating directly on the device without Xcode. This is in fact how I discovered it.

You should report a bug to Apple, especially since you have a short program that will reproduce it. I will do the same.

One key difference: In my case the failure is in writing the default. The previously written value remains in NSUserDefaults. Sometimes one key is successfully written while another is unchanged.

A similarly very intelligent DTS response from my own support request. Basically, killing using Xcode is more murderous than anything that would naturally happen on the device (even the double-Home-click-and-upswipe method) and since everything is abruptly crashed when Xcode halts it, the lazy writing of NSUserDefaults can fail, or be only half completed.

And indeed, pure on-device testing of the app, without Xcode involved, shows that everything does get correctly written to NSUserDefaults when the app is terminated.

I have closed my own bug report.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!