Cocoa bindings and plists

Discussion in 'Mac Programming' started by RobRiley, May 1, 2009.

  1. RobRiley macrumors member

    Joined:
    Feb 4, 2009
    Location:
    London
    #1
    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 :)
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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:
     

    Attached Files:

  3. RobRiley thread starter macrumors member

    Joined:
    Feb 4, 2009
    Location:
    London
    #3
    You legend! That is really helpful for me. Thanks so much :)

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

Share This Page