After reading this thread: NSUserDefaults not present on first run on simulator
I know it's quite easy to store some app data in the [NSUserDefaults standardUserDefaults]. But if other开发者_如何学Python applications also happen to use the same key to store their data, is this possible that my app data gets overwritten?
Many thanks to you all.
No, each application has it's own defaults, saved in a different file based on the application's bundle ID. On the iPhone (and simulator) each app has it's own home directory too, and can't access other app's files.
No. When you store something in NSUserDefaults standardUserDefaults, it's primarily a collection for your application. Other apps on the iPhone can't store there.
However, if you read keys other than what you stored, you may get back a value from the system database. This won't be other applications' data, but something related to the iPhone itself. I think the keys are undocumented, though.
Each application has its user defaults sandboxed from each other. You won't run into any collisions.
精彩评论