Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
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.
 

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
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.
 

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
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/?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.