(OSX) Interface Builder 3 examples?

Is 10.5 supposed to come with different Developer/examples samples? I ask because I'm looking for an example of using Interface Builder to work with toolbars, and everything in my Examples folder looks like it's old Interface Builder 2.x where the toolbars are all done manually in the code.
A quick search of the apple dev. site doesn't bring anything up...
thanks.

Brian Postow wrote:
I'm looking for an example of using Interface Builder to work with toolbars
A quick search of the apple dev. site doesn't bring anything up...
In my experience, Apple's otherwise good examples lean towards programmatic deployment, rather than IB insider tips, etc.
I've learned to look off-world for clone-worthy IB samples.
I've also found that there seems to be two camps when it comes to P vs. IB. My take on it is that visual types gravitate towards IB, where hands-on types prefer inside Obj-C.
In my case, IB lets me prototype at a pace that suits my discovery-to-effort ratios. I can wire things up fast and far enough to get a glimpse of what I want without wading into the deep end until I find something worth committing to.
Just remember that IB is late-to-the party, and reference examples are still being grown...might be a bit longer before a substantial number of examples are easily found, and even then, they will risk being made obsolete (by degree, of course) as new SDKs w/new deprecations, etc. surface.

Similar Messages

  • How to instantiate a control in code instead of using Interface Builder ?

    I really appreciate the combination of the interface builder and Xcode altogether.
    However when I am learning QT, I realize I had been pampered by Apple's Design to a certain extend as I only need to create say a NSLabel instance and use Interface Builder to do the linking and never have to worry about instantiating the Object myself.
    But I'm curious, what is the way to instantiate a new hmmm say...NSLabel in the code ?
    NSLabel* label = new NSLabel();
    Then what ?
    What you are seeing here is how QT did it, could anyone create an equivalent in ObjC ? No fancy code please, just bare minimum.
    #include <QApplication>
    #include <QWidget>
    #include <QLabel>
    int main (int argc, char * argv [ ])
    QApplication app(argc, argv); //NSApplication in ObjC
    //These two lines merely created a window and set the title bar text.
    QWidget* window = new QWidget();
    window->setWindowTitle("Hello World");
    QLabel* label = new QLabel(window);//Create a label and inform the it belongs to window.
    label->setText("Hello World");
    window->show();
    return app.exec();
    Message was edited by: Bracer Jack

    Hi Jack -
    I think my best answer will be something of a disappointment, because I don't know how to show a one-to-one correspondence between the code you're working with and a Cocoa program. The main function of a Cocoa GUI program for OS X will look something like this:
    #import <Cocoa/Cocoa.h>
    int main(int argc, char *argv[])
    return NSApplicationMain(argc, (const char **) argv);
    As you commented, we could draw a correspondence between the first statements, but after that the functionality of the Cocoa program is going to be spread out in a way that makes for a rather tedious comparison. The only way I know to answer your question in less than 5000 words, is to skip ahead to one of several points in the startup sequence where the programmer can intervene with custom code.
    For example, a common way to get control would be to program a custom controller class and add an object of that class to the main nib file which is loaded during the startup sequence. By making a connection to the Application object in that nib file, the custom object could be made the delegate of the Application object, and if we then added a method named applicationDidFinishLaunching, our code would run as soon as the application's run loop was started.
    Now I finally have enough context to directly answer your question, so here is the code to create a label and add it to the key window at launch time:
    // MyAppController.m
    #import "AppController.h"
    @implementation AppController
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    NSLog(@"applicationDidFinishLaunching");
    NSRect frameRect = NSMakeRect(150, 300, 150, 30);
    NSTextField *label = [[NSTextField alloc] initWithFrame:frameRect];
    [label setEditable:NO];
    [label setStringValue:@"Hello World!"];
    [label setFont:[NSFont labelFontOfSize:20]];
    [label setAlignment:NSCenterTextAlignment];
    NSView *contentView = [self.window contentView];
    [contentView addSubview:label];
    @end
    If I needed to develop a worst case scenario for this thread, the next question would be, "Ok sure, but your code still needs a nib to start up. I want to see a Cocoa GUI program that doesn't require any nib".
    It turns out that it's quite easy to build a simple iPhone app without any nib, but it's considerably more difficult for an OS X app. If anyone wants to see my nib-less iPhone code, I'll be happy to post it (I think I did post it here once before, and the response was underwhelming). But I've never attempted the much more difficult nib-less OS X app. Just in case you really want to go there, here's a blog that goes into the details: [http://lapcatsoftware.com/blog/2007/07/10/working-without-a-nib-part-5-open-re cent-menu>.
    Hope some of the above is helpful!
    - Ray

  • Using interface builder to create a table view and add a cell

    So I am using interface builder to make a table view. Should be easy. I drag a table view controller to my view, then it seems I should be able to drag a table view cell to the table view but it won't let me drop it down. If I do it in the documents window it just replaces the table view with a cell. Seems like this shouldn't be hard, but it's one of those things that should take 2 seconds but I have been messing with it for hours. It seems like most of the examples I have looked at in the same code don't use iB so I haven't found a good reference. If somebody can point me in the write direction let me know.

    I struggled a bit too. Here's what I did on my recently completed app. I used IB to create the basic view and add the table. That's it. Then ensure your UIViewController based class implements the UITableViewDelegate and UITableViewDataSource protocols. Your cells will come from those methods, not anything you do in IB.
    If you're creating a set of screens that just have tables that allow you to navigate up and down through the data then IB isn't worth using at all.
    Just have your views extends UITableViewController and follow some of the supplied table based example apps.
    I rewrote my first app 3 times as I slowly figured all of this out.
    Hope that helps.

  • Interface builder, running script when app opens

    Hi!
    I am trying to expand my wake script, so I have thrown it into xcode. What my wake script does is that it opens itunes and start to slowly turn up the volume, then it updates my ipod and does a few other things.
    Now this works great in script editor, I launch this app with a script which is launched by iCal.
    The first thing I want to do in xcode is to have a "I am awake" button (also called cancel…). And the only way I have gotten this to work is to have the script like this:
    on clicked theObject
    beep
    try
    tell application "iTunes" to pause
    end try
    quit
    end clicked
    on activated theObject
    -- the script.
    end activated theObject
    The reason for using activated is that this is the only handler that I have found that lets me push the cancel button. (If I for example try to use "on launched" the whole script will run, then I can push cancel, kinda defeats the purpose…).
    Any ideas?
    ahh, ****, it seems that even the activated handler doesn't work. It looks like I can push cancel, but I can't!
    Message was edited by: Oystbjoe

    Once you've pushed "buttonOne" you enter your "repeat" loop and never get out... which also means that your code never returns from your "on clicked" handler. As long as you're stuck inside your "on clicked" handler your app will not receive any more clicked events. Hence your app never gets notified of the second click on your "Cancel" button.
    Your previous post indicates you are wanting to be able to start some process (ie your repeat loop) with "buttonOne" but then potentially cancel it before it completes. From a programming standpoint that's not always easy to do... with AppleScript or any other programming language. In some cases it can be fairly difficult. And even if it's not difficult it may not be straightforward.
    One way you might be able to do this with AppleScript, depending on what your "processing" entails, is to make use of an "on idle" handler. Your "on idle" handler will be called automatically and periodically. By default "on idle" gets called every 30 seconds but you can change that by returning a positive number from your "on idle" that represents the number of seconds between calls.
    Something like this might work, but it's going to depend on whether you can break the work you're wanting to do into chunks such that you can do a little bit at a time and potentially stop between chunks due to a click on the "cancel" button.
    property doSomeProcessing : false
    on clicked theObject
    set n to name of theObject
    if n = "butonOne" then
    set doSomeProcesing to true
    return
    end if
    if n = "cancel" then
    set doSomeProcessing to false
    return
    end if
    end clicked
    on idle
    if doSomeProcessing then
    beep
    -- or do a _small chunk_ of the actual work you want to do
    end if
    return 1
    end idle
    Basically your button clicks just turn a flag on or off indicating whether you need to be doing some processing or not. All of the actual processing is done in small chunks inside your "on idle" handler. So each time your idle handler gets called you check the value of the flag. If you're supposed to be doing some processing then you do a little bit of work and return. NOTE that the "return 1" statement in the "on idle" handler is what changes the default of every 30 seconds so that it gets called every second.
    I created an AS Studio application with the code above. And I also created a separate plain vanilla AppleScript that tells the AS Studio to have one or the other of the buttons to "perform action" (as indicated in my earlier post). By running the plain vanilla AppleScript I'm able to trigger the AS Studio app to start/stop beeping every second. So whether or not you can do this mainly depends on what you're trying to accomplish and whether or not it can be broken into chunks that can be done within an idle handler.
    Steve
    PS - also note that in an AS Studio application you need to activate the "idle" handler in Interface Builder in a manner similar to how you activated the "clicked" handler for your buttons. Select the "Application" icon in the MainMenu.nib window then click the "idle" checkbox in the AppleScript Info Panel.

  • Creating an attribute editor like panel from Interface Builder

    The Attributes Inspector from Interface Builder presents the user with a great set of options that are neatly organized in folding panels. I really want to do something like this for a project I'm working on to help organize a large set of options that I plan on presenting to the end user.
    Only problem is I have no idea what this widget is called or even if its available from Cocoa. I thought it was a NSRuleEditor but I've seen no examples so I'm not sure. So if someone could help point me in the right direction that would be awesome. If you know of an example project in the Examples folder that would be even better. Thanks a lot.

    The IB toolpanel is just built out of stock IB parts but there are quite a few of them. As far as I can tell it's just an NSPanel with a toolbar at the top and then at least one NSSplitView with an NSScrollView inserted into it.
    To add something like this to your project - although I would recommend starting simpler for learning - simply drag an NSPanel into your IB window and then drag an NSScrollView on top of it and it will fill the NSPanel and you can modify it from there. You can also drag an NSScrollView directly into your nib and work on it and then drop it on the NSPanel if you want. This might make the process easier/more clear for you. If you put an NSTextView into the window it will automatically show and hide scrollbars depending on content unless you tell it otherwise.
    Custom views can be confusing but since NSPanels can be made to show themselves as soon as a program launches (I think this is their default state) your content should show up automatically which makes it easier than creating regular windows and then worrying about showing their contents.
    Do this help?
    =Tod

  • How do you make a tool bar on interface builder

    I don't know how to make a toolbar (for example: like the one safari) using interface builder.

    Might start here:
    http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptua l/MobileHIG/SystemProvided/SystemProvided.html
    In IB, you'll want to look over the objects in the libary pane/window. These are drag/drop into whatever view you're working, etc. Wiring them up of course depends on usage.
    Apple's 'UICatalog' is another good reference that you can get your hands into and push around for protos and ideas.

  • Interface Builder doesn't open

    I'm a long time developer, first-time developer for Mac. I've just started to use the Xcode tools. I've used them in the past, but I just got my new MacBook Pro and installed Xcode 3.2.1 (10m2003). I started following one of the application tutorials, building Hello World. After creating the NSView (HelloView), the next step says, "Double click MainMenu.xib and open Interface Builder then blah blah blah". So I double click on MainMenu.xib and nothing happens. I checked the Console Log and found this:
    1/3/10 12:49:33 PM Xcode\[7360\] LSOpenFromURLSpec() returned -10814 for application (null) path /Users/bpwold/projects/Hello/English.lproj/MainMenu.xib.
    Then I decided to open Interface Builder from Spotlight, which worked. I opened the MainMenu.xib file from there (which does appear to have opened), but the log also showed:
    1/3/10 12:57:54 PM \[0x0-0x215215\].com.apple.InterfaceBuilder3\[7496\] Couldn't open shared capabilities memory GSCapabilities (No such file or directory)
    So my question is: Do I have a proper install of XCode? Has something gone wrong with the install. In the past, double clicking on .xib files would produce the desired results, but apparently XCode 3.1.2 on Snow Leopard seems to have a little problem.
    Maybe someone else has run into this?
    Message was edited by: roboknight
    Message was edited by: roboknight

    apparently XCode 3.1.2 on Snow Leopard seems to have a little problem.
    Not really. The problem is with certain/early style app samples that had xibs created programmatically (back in the stone age), rather then with IB (as most current examples from Apple are).
    If you toggle the small triangle next to the offending xib in Xcode's resource window on the left, you should see yet another file...double click that one and IB should respond accordingly. If not, use the Finder and drag/drop instead. If still no joy, find another sample app

  • Interface Builder and subclassing

    Is it possible for me to have the outlet in Interface Builder pointing to a superclass... then in the code using that interface to point to a subclass?
    So for example, suppose I'm setting up an interface in Interface Builder with a HumanView (let's say this is a subclass of UIView)... suppose this is like a character in an MMORPG... and you're customizing your chaacter...
    and correspondingly in my code I have:
    IBOutlet HumanView *character;
    But I'm uncertain whether this view will be a female or male character... In my code I have two subclass of HumanView... FemaleView and MaleView... each with its own unique instance variables and methods...
    Is it possible for me to decide in the program to have make "character" a FemaleView or MaleView?
    Thanks.
    Message was edited by: iphonemediaman

    Not a problem. I did realize I should add one minor clarification.
    1) You can cast a quadralateral to a square in one instance. When you know that actual object (the structure in memory) is a square.
    So, to be complete, you can safely cast a the square to a quadralateral all day long -- you know that a square is always a quadralateral. But if you are going to cast the quadralateral to a square, you should make sure you actually have a square object. The compiler will let you do it (might show a warning), but you could end up trying to reference pieces of a square that may not actually be part of the actual object. aka (in pseudo code):
    // no issues with these two alloc/inits
    Quad *foo = (Quad *)[[Square alloc] init];
    Quad *bar = (Quad *)[[Rectangle alloc] init];
    // both would return 4
    [foo numSides];
    [bar numSides];
    // if setSideLength is only a method on a Square, then
    // first line works fine
    [(Square*)foo setSideLength:20.0];
    // this line, however, will likely give a compiler warning and then
    // an EXC_BAD* error during runtime -- bar is not actually a square
    // in memory, despite what you are telling the compiler
    [(Square*)bar setSideLength:20.0];
    I hope I didn't conuse the issue -- but wanted to clarify.
    Cheers,
    George

  • Interface Builder - Picker + orientation

    Hi all,
    I just wanted to know if there is any way to add pickers to an application from Interface Builder, or do these have to be done programatically ?
    Also, is there any way to start a nib in interface builder that assumes / forces orientation into landscape when the application is started, as opposed to all applications being started as portrait ?
    Thanks...

    Thanks, but I'm still struggling to understand the interaction between Interface Builder and iPhone. I've built a xib that contains a UIView that I changed the class of to UIPickerView.
    After this, what do I need to do? Looking at the UIPickerView docs, it looks like I need to provide a delegate and a datasource.
    I can find examples of implementing the whole thing in code, but how do I do part of it in IB like I've done, and then provide the delegate and the datasource in the code ?
    I'm assuming that I need to associate an object / class with the Picker, but I'm not really sure I understand that at all.
    Are there any good starter docs out there for building an app in IB and then working with that in Xcode ?
    TIA,

  • Interface Builder Library?

    Is there a library of additional items which can be imported into Interface Builder, either from Apple, third-party, or open-source projects?
    Apple provides all the basic elements, but either I haven't learned how to take full advantage of advanced use of the existing items, or some other common items are missing. I would think with the insurgence of new developers and platforms, specifically the iPhone and Cocoa Touch, there might be additional packages or libraries available.
    For instance, I like the revolving picker, but for something a little less flashy, a simple pop-up list similar to a web-based select, would be a great little item, allowing for single or multi-item selections.
    I'm sure I'm not the first or only developer interested in being to re-use well crafted elements.
    Another example is the info light or info dark UIButton. Since I didn't feel comfortable crafting my own programmatically, I put an info light button in my xib file, and programmatically put an opaque circular graphic right over the info graphic, userInteractionEnabled=NO, and voila, functionally the same, but the screen presence is different.
    Having a larger library seems like just the thing.
    Are there any out there?

    Have you looked over Adding Custom Objects to the Library in the Interface Builder User Guide? That feature doesn't provide everything you're asking for, but it might come in handy.
    It might be good to remember that IB doesn't create objects, and the xib file doesn't include instructions on how to create an object. IB just specifies an object which must already be defined somewhere. So any 3rd party icon library would not only need to have an API for IB, it would also need to include a framework or static library to actually create the new objects represented by the icons.
    Another point to remember is that the appearance of an object in IB doesn't determine what an object's class will be at runtime. That's determined by the Class you specify in the Identity Inspector. So if you have a custom class in your own library, you can use that class in IB by dragging an "Object" (cube) icon into a window, then setting that icon's identity to the custom class.
    Hope some of the above is useful to you!
    \- Ray

  • Interface Builder Fold Down Panel?

    Hey Thanks to everyone on these forums there a huge help.
    I'm trying to recreate the fold down effect that the open file panel has were the panel like folds out of the top of the app. Is there a way I could recreate this in Interface Builder or possible its called something else.
    Thanks

    yz4now wrote:
    What would that animation or effect be called?
    Drop-down menu. This is a standard menu example for most routine applications.
    Using Xcode, create an new project....Mac OS X Application, Cocoa Application.
    Open the 'Resources' folder on the left and double-click on 'MainMenu.xib' to open it in Interface Builder.
    Using the MainMenu.xib window in IB, toggle the small triangles on the left to show the items in that menu. From there you will see the contents and the menu. This menu will drop-down in your application to show whatever contents you are working with.

  • Interface Builder w/ Xcode folder refs

    when i set up xcode with folder refs interface builder does not see my images in the dropdown list. i actually have to type out the path and ib will show a broken image. is there anyway to fix this?

    Note that *AppleScript Studio* has been deprecated in Snow Leopard - AppleScriptObjC is the new framework. You can still edit Studio projects, but the project templates have been removed and you will need to enable the AppleScript palette - see the release notes.
    Assigning a handler (IBaction) to a button (or any object) is pretty easy - create a handler in your script that takes a single parameter and name it with a trailing underscore (the naming conventions are also in the release notes), for example:on doButtonStuff_(sender) it will appear in *Interface Builder* under the *Connections Inspector* for your application delegate - from there you can make a connection from your object to the handler. MacScripter has some tutorials for AppleScriptObjC in Xcode, and I also have a button example project (it's not much of a tutorial, though).

  • Style display problem in Web Interface Builder (OWC)

    Hi,
    I wanted to create my own styles for my BPS Planning Layouts and then
    use it in the Web Interface Builder on Office Web Components.
    Step 1 : I saved a Planning Layout in my hard disk.
    Step 2 : I created my styles as explained in the SEM BPS help notes (->
    Format, Styles ) and saved it in Excel.
    Step 3 : I used UPP_MASTER_CHECKIN in tn se38 and then
    UPP_LAYOUTS_UPDATE_WITH_MASTER in order to apply the master template in
    all my layouts.
    Step 4 : I put my styles in all my layouts in the BPS0 (for Lead
    Columns, Head Datas and Data Columns).
    Step 5 : Once I generated my layouts in the BPS0, the result was what I
    expected : the styles were right and at the good place. I checked
    publish for the WEB for all the layouts that needed it.
    Step 6 : I created a Web Interface with BPS_WB using my layouts as
    Office Web Components (Web Excel : true)
    Step 7 : I generate my Web Page
    And when I look at my layouts the styles disappeared....
    However if I modify the Standard Styles (SEM-BPS-headata or SEM-BPS-
    sub1 for example)and put them in my layouts then it works !!!! The
    modified styles appear in the Web Interface Builder.
    I do not understand why it works with the standard styles and not if I
    create and put my own. Did I something wrong or missed a step or is a problem with SEM BPS ????
    Thank you for your help
    J-Michel

    Sorry that note say :
    <b>Styles. Consequently no changes to the SAP standard styles are taken over to the OWC</b>
    I try fix that problem too, go check new design in BW-BPS.

  • URL functionality in Web Interface Builder for BPS

    Hi,
    I have web enabled a planning folder and in the Web Interface bulider I am trying to enhance it. The clients requirement is to be able to select a file by clicking on a URL on a shared drive, based on variable selection. The file name is smart coded
    e.g.
    the files may reside in
    shareddrive\
    if the value in variable for version is 100, then the url should be "
    shareddrive\100.xls" and on cliking on this url, the file should open
    if the version value is 200, then the url should be "
    shareddrive\200.xls".
    In the Web Interface builder, I have created subcomponent 'URL'. If I give a fixed path for the URL say "
    shareddrive\100.xls" and clicking on it opens the file.
    I am however unable to parmeterize it. I tried using Javascript in the "Goto URL" attribute, but it doesn't work
    Any help is appreciated.
    Thanks,
    NS

    Hello Nimmi,
    here's an example that adds a button to launch the file. "VarvlSel1" is the technical name of the variable (dropdown box).
    Regards,
    Marc
    SAP NetWeaver RIG
    <span>
    <a href="#1" onclick="open_file();return false;"
    class="urBtnStd" id="OpenButton1" ct="Button"
    style="white-space:nowrap;"
    OnMouseOver="javascript:window.status = 'Open File';return true;"
    title="Open File">
    <nobr>Open File</nobr>
    </a>
    </span>
    <script type="text/javascript">
    function open_file () {
    var variable1 = document.all("VarvlSel1");
    var value1 = variable1.options[variable1.selectedIndex].text;
    var url1 = "
    sharedrive
    folder
    " + value1 + ".xls";
    // alert(url1);
    var window1 = window.open(url1,"Window1","width=310,height=400,left=100,top=100");
    </script>

  • How can I access instances from Interface Builder?

    Hello!
    How can I access instances build from the Interface Builder? For example, i know how to access Controller classes = just setting the class in the view identity. But I am missing some "connection" to my navigation controller. IB uses one, but in my code, i dont have one.
    All my xibs file owners have as their identity class a View or TableView Controller. But shouldnt they have a navigation controller as identy if the View or TableView is using a navigation Controller?
    thank you..

    thank you, .. i know.. the problem is, that i have different xib files, but i am not sure how i can connect them with their navigation controller / tabbarcontroller.
    it seems, that
    NSLog(@"pushing next view..");
    [[self navigationController] pushViewController:nextViewController animated:YES];
    is not enough. On the console, i can read pushing next view.. but it doesnt come up to the screen.

Maybe you are looking for