I am seeing this strange behavior, which seems to be specific to my concrete device or my building environment (my colleague does not have this problem when building the same code). Every time I start the app from Xcode data in NSUserDefaults
is gone. Same happens when I kill the app and restart it.
I have tried restarting Xcode, my laptop, device, cleaning the project and derived data - nothing helped. I do call synchronize()
after updating data, so it should be persisted. But it does not. And I don't see any errors in console.
What is the cause of this problem? What do I do to fix it? Is this caused by some fancy hidden project setting?
I would also like to know whether data is reset on restart or not saved when synchronize()
is called. Can I inspect the contents of file in which NSUserDefaults
are saved?
UPDATE: An interesting detail. After killing the app in Simulator, I cannot start it from Xcode again (getting "The operation couldn’t be completed. (LaunchServicesError error 0.)
"). I have to use iOS Simulator -> Reset Content and Settings
to be able to run the app in emulator again.
UPDATE 2: I tried to find the file in which iPhone Simulator stores NSSharedPreferences
as suggested here, but it is not there.