Preference Pane in XCode 2.1

Discussion in 'Mac Programming' started by Dave the Great, Aug 3, 2005.

  1. Dave the Great macrumors regular

    Joined:
    Jan 27, 2004
    #1
    I am new to XCode. I am interested in creating a preference pane. Does anyone know of any good tutorials?

    I found a couple of preference pane web pages, but they seem quite outdated, from ~ 2001, and do not show creation in XCode.

    Thanks.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    What do you want your preference pane to control? The basics are really simple. Start XCode and choose New Project. Select Preference Pane from Standard Apple Plugins. Put the UI for your pane in the Nib file and the supporting code in the <your pref pane>Pref.m file.

    That's about it.

    To give it a custom icon overwrite the <your pref pane>Pref.tiff file.
    To alter the name displayed (so it's not the name you gave the project) alter the NSPrefPaneIconLabel value in the Info.plist file. Also make sure you set the bundle identifier to something sensible.

    The difficult bit is making the pref-pane control whatever it's meant to control. If it's your own code you can simply write to the standard user defaults for your app.
     
  3. Dave the Great thread starter macrumors regular

    Joined:
    Jan 27, 2004
    #3

    Yes, opening and starting it up was no problem - even with no prior use of XCode.

    I figured out that I needed to click the nib to open up the interface builder. I then built the interface. I then found out that I needed to open and start up the inspector. I created an outlet and found out that to make the connection you had to control click the file owner instance and drag to your component on the window.

    I just now am not sure how to create the action. Am I still supposed to do it Interface Designer - I see that if you click a component on your window - like a button- there are actions listed under the connections on the inspector? Or am I supposed to go back into XCode to actually hand code it.

    I wanted to make a pane to start/stop JBoss. Exactly, like the MySQL Pane - it has a single button to start/stop the server. It has a checkbox to allow you choose if you want to start MySQL up at start-up.

    Actually, I would be happy with just the single button to start/stop the server.

    Thanks for your help!!
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Your basic question was a bit misleading then! You really meant to ask: "How do I get started with programming in Cocoa?"

    Have a look at the basic tutorials and get a feel for how you do things. Perhaps buy a book? Or take a look at macdevcenter or cocoadevcentral?

    Once you know what your doing you'll discover the hooking the interface to the implementation code is easy. Start/stopping the server, well you're pretty much on your own as that is going to be totally specific you your pref pane and will not be covered by the framework.

    This is probably a good starting point.
     
  5. Dave the Great thread starter macrumors regular

    Joined:
    Jan 27, 2004
    #5
    Well, maybe slightly misleading. :)

    I was just hoping to be able to do this without getting too involved in learning Cocoa right now, but I see that is probably an impossibility. I am just surprised no one created a JBoss pane by now.

    Why would starting/stopping the server be so difficult through a pane?

    I just thought the MySQL pane was slick and JBoss should have one, too.

    Thanks for your time and help!!
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    It's not necessarily difficult, just it won't be covered by any tutorials or sample code. Assuming there are some scripts to start and stop it it should be as easy as using NSTask to run the script.
     

Share This Page