I have created an app which uses Application Settings and user defaults following the example in the book “Beginning iPhone Development”. In some cases my settings seem to disappear.
If I launch the simulator I can go into settings and see it, I can then open my app and my settings can be read from within the app. If I then leave my app and go back into the settings screen I can no longer see the settings for my app!
I’m new to iPhone dev, is there something obvious that I’m overlooking?
Thanks.
Seen that regularly, not worried so far. When developing app, I reinstall application into iPhone simulator several dozens of times a day. When opening Settings application I usually don’t see my app at first. Just close and reopen Settings and now it’s there.
It’s the way simulator works (see below). If you want to test your app settings, close and reopen your app. Don’t reinstall, since that overwrites your existing settings.
Quote from Apple’s docs (bit.ly/1alQ2Y): “Each time you reinstall your application, iPhone OS performs a clean install, which deletes any previous preferences. In other words, building or running your application from Xcode always installs a new version, replacing any old contents. To test preference changes between successive executions, you must run your application directly from the simulator interface and not from Xcode.” (thanx cagreen).
Btw a bit related: I made changed into app settings and did not see those values in simulator. When checking actual .plist files I always found there the real up-to-date values. Had to uninstall and reinstall my app, overwriting did not work. Sometimes even this didn’t work, either Xcode or simulator was caching old values! Partial solution was to start updating application version number (CFBundleShortVersionString).