Nikita Rybak
Nikita Rybak

Reputation: 68016

NSUserDefaults vs CFPreferences, what to consider

Apple provides documentation for managing user preferences through both Core Foundation and Foundation Kit. It also doesn't offer any help with choosing one or another, except for stating that they're indeed different ("not toll-free bridged").

So, I'm interested, is there anything I should consider selecting configuration mechanism for the application? Or should I just toss a coin?

Thanks!

Upvotes: 6

Views: 3513

Answers (2)

yijiem
yijiem

Reputation: 369

NSUserDefaults reads and writes to the user scope, while CFPreferences supports writing to both user scope and machine scope. You can use CFPreferences for a machine-wise setting which can be applied to all users using the application on the same machine.

Upvotes: 1

Jonathan Sterling
Jonathan Sterling

Reputation: 18375

You are supposed to use NSUserDefaults, which is absolutely the default choice. I suppose you could use CFPreferences, but unless you had a good reason to make that choice, I'd steer clear of CF-APIs.

Upvotes: 3

Related Questions