PDA

View Full Version : Cocoa bindings and plists




RobRiley
May 1, 2009, 04:58 PM
Hi,

Ok so I have set up a preferences view for my application and bound it using an NSUserDefaults controller. Simple. But I want different parts of my app to bind to different plists in different places. Is it possible to use multiple NSUserDefaults controllers bound to different plists in a single app? If so, how? And where would I specify the filepaths for these files?

Thanks :)



kainjow
May 5, 2009, 02:15 PM
NSUserDefaults uses the app's bundle identifier for its plist, so you cannot use it for other plists other than preferences. What you need to do is implement your own custom class that reads and writes to a plist and supports KVC for bindings. Here's a sample project that demos one way to do this:

RobRiley
May 5, 2009, 03:04 PM
You legend! That is really helpful for me. Thanks so much :)

You haven't written any books on this by any chance?!