views:

303

answers:

3

On the iphone can other apps read the values you've set using NSUserDefaults?

Not including jail-broken phones.

I'm considering saving the customer's userid/password for our service.

Thanks,

A: 

First of all, you should be saving userid/password in the keychain, not the user defaults.

Secondly, yes, other applications can read the NSUserDefaults. The defaults are unix style user defaults not application defaults. Under the old NextStep OS, an individual users defaults would follow them from networked machine to networked machine. The idea is that users have preferences for things like default fonts that all applications should use.

The iPhone inherited that by being a slimmed down version of MacOS X. I am not sure how thorough the sandboxing on iPhone apps is that regard. It might be possible to worm a way through the system if you knew the proper keys for domains and values.

Certainly, Apple strongly discourages keeping any sensitive information in the user defaults.

TechZen
+6  A: 

No, other applications cannot see your data. That said, you should probably consider using the keychain on the iPhone to store sensitive data like usernames and passwords.

Paul Wagland