Back to my preference pane project.

Discussion in 'Mac Programming' started by Denarius, Oct 19, 2008.

  1. Denarius macrumors 6502a

    Denarius

    Joined:
    Feb 5, 2008
    Location:
    Gironde, France
    #1
    Hi folks,

    I've got an app up and running, but it's all back end/command line type stuff so I thought that I was long overdue to put what I've managed to learn about Cocoa into practise for the first time and make a GUI for it.

    It has three objects that it displays in the nib, which are an NSTableView for printers (corresponds to a Dict in the plist) in one tab and an NSTableView for servers(again corresponding to a dict) along with Broadcast IP address text view (a string in the plist).

    First of all I want to see whether this sounds like a decent structure or if there are any problems with it:

    • Printer preference pane subclass
    • Server preference pane subclass
    • Broadcast IP subclass
    • wopol Controller class - for reading and writing to the preferences file

    The other question I have is should the function -(void)mainViewDidLoad be treated just the same as -(void)init in a normal class?

    Thank you all.
     
  2. Denarius thread starter macrumors 6502a

    Denarius

    Joined:
    Feb 5, 2008
    Location:
    Gironde, France
    #2
    Actually, having started working on setting up the outlets I have a feeling I'm getting something wrong and after having trawled the web and being unable to find anything on prefpanes in XCode 3 I now have another issue.

    I set up the outlets in the NSPreference sub class, but when I put an NSObject into IB and trying to associate the NSObject with the class, rather than seeing the expected outlets in IB I have a list of outlets like _firstKeyView, _initialKeyView. What have I done wrong and what do I need to do to get the outlets I expect.

    Also, some (from way back in 2003, the latest I could find) preference documentation on the apple site mentions
    Code:
    - (id)initWithBundle:(NSBundle *)bundle
    needing to be in the preference subclass. The template didn't create this when I started the preference project so I'm wondering if this method is now obsolete and whether I now just need the - (void) mainViewDidLoad delegate method that was created automatically?

    Thanks in advance.
     
  3. Denarius thread starter macrumors 6502a

    Denarius

    Joined:
    Feb 5, 2008
    Location:
    Gironde, France
    #3
    Anyone there?

    Wow, stony silence. I'm starting to think I've said something wrong!

    Thankfully, I've pretty much resolved all of the issues I had including the structure (found an old post of robbieduncan's that was very helpful indeed).

    My only remaining question is what is the recommended method to read and write the plist from /Library/Preferences/?
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    You should avoid /Library/Preferences and use the user's home directory instead (~/Library/Preferences). If you're doing this you can use NSUserDefaults (but since you're in System Preferences you can't use standardDefaults). Or just use an NSDictionary to read/write the plist.
     

Share This Page