Load Class in Interface Builder 3

Hello,
i am trying to get started with Cocoa after having worked a while with Xcode & smaller AppleScript based projects.
As my idea was to create a menubar-based (NSStatusItem) service app for myself i started with this tutorial:
http://files.semaja2.net/NSStatusItem%20-%20ObjC.html
Unfortunaly it seems like there was a change in Interface Builder regarding loading Classes from Version 2 to IB version 3
The tutorial tells me to (about the middle of the tutorial):
Rename the “NSMenu1” to “StatusItem”, following this in “Interface Builder” >>choose from the menu “Classes > Read Files..” now select the AppController.h >>file, Once the file has been read it should change out project view to “Classes” >>from here find the AppController item and right click on it and select >>“Instantiate AppController”:
I was able to follow the tutorial until there without problems but it looks like the Classes-Tab is gone in IB 3.x.
So i feel somehow unable to finish this small tutorial.
how would i do this step in Interface Builder 3.x ?
Any help is heavily appreciated.
Best regards
fidel

fidel-castro wrote:
I was able to follow the tutorial until there without problems but it looks like the Classes-Tab is gone in IB 3.x.
So i feel somehow unable to finish this small tutorial.
how would i do this step in Interface Builder 3.x ?
You're right, this has changed. I'm currently using IB 3.1.1 but I believe the changes appeared in IB 3.
Once you've done the "Read class files" and selected your AppController.h file IB should know about your class.
In order to instantiate your AppController in IB first go to the Library window and find the "NSObject" (it will appear as a blue cube). Drag one of these NSObject's from the Library window and drop it into your MainMenu.xib window along with the other icons that appear there (File's Owner, First Responder, Application... etc).
Now you will have created an instance of an NSObject in your MainMenu.xib file. And, since your AppController class is a subclass of NSObject (and IB knows this since you've had it read in your AppController.h file) you can now change this NSObject instance into an instance of your AppController.
Select the NSObject icon in the MainMenu.xib window then go to IB's Inspector window and click on the next to last icon in the top tool bar. This should change the Inspector window's title bar to say "Object Identity" and the Class Identity in the first text field should be set to NSObject. You should be able to type "AppController" into this field (or click the popup and it should show up in the popup list. Once you've done this it will transform the NSObject instance into an AppController instance.
You'll see another slight difference between IB 3.x and the tutorial when you do the <Control>-Drag between items to connect up the outlets and actions. Instead of finalizing the connections in the Inspector window like the tutorial says you'll get a small popup window right next to the item you're connecting to that will list the available outlets/actions you can connect to. Simply click the one you want. You can still double-check your connections in the inspector window though.
Steve

Similar Messages

  • Can I no longer browse classes in interface builder?

    in tiger, I used to be able to browse classes in interface builder, and from their I could create subclasses, and create actions and outlets. then I could create files for the classes from the classes menu. then when I went back to xcode I would have empty class file templates that I could then write the methods for.
    also, I could easily instantiate my class via the classes menu.
    alas, now I cannot find these features. have they dissappeared entirely? is there an equivilant way to do this?

    I found that disturbing too...
    However the system changed completely. You can no longer define the super-class directly in Interface Build, however you can still define classes there with IBOutlets and IBActions.
    First, to instantiate a blue cube as a custom object, simply drag a blue cube from the Library windows inside : Library --> Cocoa --> Objects & Controllers --> Controllers.
    To set the class, go in Identity inspector (CMD + 6) here you'll be able to define the class name, its outlets and its actions, you can even define the action argument type (sender) here, however, weirdly, they took the ability to add the colon directly at the of the method name, so you'll have to add it yourself.
    However, Apple documentation advise you to add methods and outlets directly in Xcode and not in IB, "Whenever you want to create a new controller class, or add an outlet or action to an existing class, do it in Xcode."
    Indeed, if IB is opened at the same time, it will update the class's outlets and actions directly, Xcode and IB are more binded together than before.
    Message was edited by: PsychoH13

  • Can't load class 'mx.transitions.BroadcasterMX'

    I have a flash piece that I programmed last year in CS4 and now I had to change a little bit of the content, nothing code related, just modify an image. Now I'm using CS5 but when I try to publish the movie, I get an error: Can't load class or interface 'mx.transitions.BroadcasterMX' (I'm translating fom spanish)
    I have reduced the fla to the minimal expression. just a frame with the following AS:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    new Tween(MCcore, "_y", None.easeNone, MCcore._y, 0, 2, true);
    stop();
    Where MCcore is just a square in the bottom of the screen that should move to the top.
    I've checked that BroadcasterMX is in the correct path of the hard drive and is not corrupted.
    I've tried with several publishing options from flash player 6 to flash player 10 but always the same error.
    As I said, the movie compiled correctly in CS4. What is going wrong?

    As I said, this movie was compiling correctly in Flash CS4 using ActionScript 2
    BroadcasterMX.as is called from Tween.as. If you have Flash installed in your machine you can go to your user files path and then to Adobe\Flash CS5\es_ES\Configuration\Classes\mx\transitions and you will find it there (maybe you have to replace es_ES by en_US or whatever your install language is)
    any other more helpful answer?
    Anyhow, I would be insterested in any other code that moves the clip from the bottom of the screen where it is to the top in two seconds while the rest of the movie keeps running. (the original code did more things and also moved the clip in the x coordinates and changed size and opacity, so there were 4 tweens and several other objects that also Tweened in and by the stage)

  • File's Owner does not show methods in Interface Builder 3.2.6 but the class is set correctly and the nib on the lower left is green

    Hi, I'm trying to make my first IPhone app. After having problems with interface builder the first time I coppied the code directly from a tutorial in case I made any mistakes. I saved the program, and re-opened the .xib file. Right clicking  File's Owner does not show a list of methods. I've been looking around for solutions for this but have not gotten anything to work. I tried deleting the default .xib and creating a new one through file-> new file. This did not help. I did notice that File's owner was showing up as a light blue cube apposed to a yellow one now and found that a bit odd but otherwise nothing changed. I opened the library menu and selected helloWorldiPhoneViewController so it would show up in the view port. I set the class field of File's Owner to hellowWorldiPhoneViewController. File's Owner still does not show methods when right clicked or when a line is dragged over a button. I read somewhere that the color of nib on the lower left of the viewport may indicate a problem, but it is green not indicating any issue. Every solution I found for someone else seems nto to work for me and I don't know how to continue.
    here is the .h file just in case:
    //  HelloWorldViewController.h
    //  HelloWorld
    //  Created by Paul Peelen on 2011-03-14.
    //  Copyright 2011 9697271014. All rights reserved.
    #import <UIKit/UIKit.h>
    @interface HelloWorldViewController : UIViewController {
            UILabel *textLabel;
    @property (nonatomic, retain) IBOutlet UILabel *textLabel;
    - (IBAction)changeTheTextOfTheLabel;
    @end
    I'm trying to connect changeTheTextOfTheLabel to a button and textLabel to a label

    You need a parameter for an interface builder method. The type should be id and the name is typically "sender". It would look like this:
    - (IBAction)changeTheTextOfTheLabel: (id) sender;
    Be careful about those tutorials. Many are ancient and do not correspond to current Xcode behaviour.

  • Class or interface could not be loaded?

    I am very new to coding in general, ini fact this is my fisrt crack at it, and right now I'm just going off a tutorial, but for whatever reason i'm having an issue that the class/interface not being loaded.
    My code right now is:
    class ship extends MovieClip
         var velocity;
         function onLoad()
              velocity = 10;
         function onEnterFrame()
              _x = _x + velocity;
    Essentailly when I test play this i should see my object going across the screen, but instead it does nothing and i get the error:
    "Symbol=Ship, layer=1, frame=1, Line 1      The class or interface 'Ship' could not be loaded."
    I do have the .fla and .as saved in the same file, but does it matter where that file is located, or have I come across some basic mistake or..?
    I'm using ActionScript2.0 for this.
    (Very secondary, but does anybody have any tutorial reccomendations?)

    You have the .fla and .as saved in the same file? Or the same folder?
    Also you will notice that you have
    class ship extends MovieClip
    But it looks like for your symbol you have given it a defintion of Ship. (Caps matter!)
    Your code should be capitalized, as should the name of the Ship.as file. You will notice that the Flash classes all start with a cap and that instances start with lowercase letters. You don't have to do this, but it makes it easier to know what is what.
    As a recommendation I would recommend the book by Keith Peters, Making things move. And also unless you have an overwhelming need to learn AS2, I would recommend skipping it and moving right to AS3.

  • The class or interface 'MouseEvent' could not be loaded

    I am creating a swf file that would get populated with images
    and text taken entirely from an XML file from the local folder. All
    i need to do now is manouver between the images using a click of a
    button. Say there are some images lined up one below the other and
    there would be a button on screen.. on click of which the focus has
    to shift from one image to the other. To achieve this functionality
    i have created a Movie Clip that would act as the BG for the Images
    to show that the image is in Focus. I check the current location of
    the Movie Clip on cick of the button and then set the next location
    of the Bg movie clip accordingly.
    The Functionality of moving/changing coordinates of the movie
    clip on click of a button works fine when done separately in a new
    file, but when combined with the code where the XML gets parsed and
    the Imges are set on the UI, it gives me an error -- "The class or
    interface 'MouseEvent' could not be loaded"
    I'm adding my code below
    RPNext_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    function clickHandler(event:MouseEvent):void {
    trace("here");
    var XCo = SwatchBGRght_MC.x;
    var YCo = SwatchBGRght_MC.y;
    trace("X coordinate::"+XCo);
    trace("Y coordinate::"+YCo);
    if(YCo==145){
    //SwatchBGRght_MC.y = 282.2;
    if(YCo==282.2){
    //SwatchBGRght_MC.y = 419.4;
    if(YCo==419.4){
    //SwatchBGRght_MC.y = 145;
    __________________________________

    Well, I guess I'll have to see the code, that is NOT
    functioning, to track this error down.

  • The class or interface could not be loaded...?

    I'm doing a simple link code. I've tried many diferrent ways to do this but this error keeps comming up saying The class or interface could not be loaded...
    home_btn.addEventListener(MouseEvent.CLICK, gotoURL);
    function gotoURL(event:MouseEvent):Void
    navigateToURL(new URLRequest("my site"));
    This is the most recent method I've tried in doing this. I've tried changing the publishing settings of the document to and from Action Script 3.0- using an import command. But thats too complicated. I know this is simple... but can anyone please help?

    Thanks, but whenever I change the publish settings back to As3 the flash tween gets caught in a loop and it doesn't end, it just re-runs the swf over and over again. I'm not sure how to fix this problem now.
    I even tried to add a stop(); at the beginning of the new script.
    stop();
    home_btn.addEventListener(MouseEvent.CLICK, gotoURL);
    function gotoURL(event:MouseEvent):Void
    navigateToURL(new URLRequest("http://www.knirv.com"));
    I'm still getting an error message saying "1046: Type was not found or was not a compile-time constant: Void."...However, I'm sure your advice to upload to my server will solve this. Much thanks for the expertise

  • The class or interface 'flash.utils.ByteArray' could not be loaded.

    Hi all, I am trying to use some of the new functionality that
    is available in AS3 and I keep getting an unfathomable error
    message. The code that I am using is at the bottom of this post.
    No matter what I do I keep getting the following error when I
    compile this code
    The class or interface 'flash.utils.ByteArray' could not be
    loaded.
    And the source line is
    var pixels:ByteArray = srcBmp.getPixels( new
    Rectangle(0,0,imageWidth,imageHeight) );
    Can anybody see what I am doing wrong here? This is driving
    me crazy!!

    I AM THE ULTIMATE CHUMP!!!!!
    I finally figured it out, you can tell I am new to Flash!
    Anyway, I assumed that by selecting ActionScript 3.0 in my
    Actions frame then this ias the version that would be used when the
    movie was exported. However I have found out that I should also
    have been setting the ActionScript version to 3.0 in the Publish
    settings page to. I feel like such an idiot!!!

  • The class or interface 'mx.remoting.Service' could not be loaded.

    Flash 8 was reinstalled on a new machine upgrade. Application
    that uses flash remoting is unable to be updated after this new
    install error when trying to publish application is :
    The class or interface 'mx.remoting.Service' could not be
    loaded.
    is this because I do not have the "Flash Remoting for Flash 8
    ActionScript 2.0" extension installed?
    and if so do I have to re purchase this or can it be
    reinstalled from the old hard drive of the replaced machine? would
    it be a *.mpx file?
    The application works but I can't publish any new
    modifications without getting this error. and this just started
    since my machine was upgraded.. so I hope this is the problem...
    thanks in advance....
    chuck

    The flash remoting components are on adobes website for
    download
    here

  • AS 2 Error: The class or interface 'Event' could not be loaded.

    Hey, I'm new to the forums and I have problems with Flash that i just cant fix. I have this error that keeps telling me how "The class or interface 'Event' could not be loaded. The error is on the 5th line of the code:
    1  stop();

    3  addEventListener(Event.ENTER_FRAME, preLoad);

    5  function preLoad(e:Event):void{
    6      var bytestoLoad:Number = loaderInfo.bytesTotal;
    7      var numberLoaded:Number = loaderInfo.bytesLoaded;
    8      if(bytestoLoad == numberLoaded){
    9          removeEventListener(Event.ENTER_FRAME, preLoad);
    gotoAndStop(2);
    } else {
    _root.preLoader.preLoaderFill.scaleX = numberLoaded/bytestoLoad;
    _root.preLoader.bytesPercent.text = Math.floor(numberLoaded/bytestoLoad*100) + "%";
    I know that the code is for AS3 but I cant switch to AS3 atm and I need the same code, but for AS2. So, can anyone convert this for me? By the way, this is supposed to be a preloader and I am putting this on the 1st frame. I have so extensions (.as), just the .fla file.
    Also, I am using the newest Flash, Adobe Flash CS6.

    Just search Google for an AS2 preloader tutorial instead of trying to convert AS3 to AS2.

  • Can't connect to server "Cannot load Interface Builder File "NSAlertPanel"

    all of a sudden, one of my Macs cannot connect to our server due to this error in the Console:
    NetAuthAgent [ 128 ] Cannot load Interface Builder File 'NSAlertPanel'
    This is on a MacPro running 10.6.4 - rebooting this computer didn't help.
    My searches on Google regarding this message didn't pull results related to connecting to a server.
    The error appears when in the Finder and you type Command + K or if you select Go in the menu and then select "Connect to Server". The "Connecting to Server" window does appear but it just sits there like it's trying to connect to our server. The login window should appear but it doesn't.
    This happens both with AFP and SMB - it never connects and that error message i posted shows up in the Console whenever I attempt to connect.
    Any ideas?
    more info: i logged in as Root and the problem isn't there so it's isolated to the other profile. the problem is, i can't always use the Root profile.
    Message was edited by: ifone_lover
    Message was edited by: ifone_lover

    I would recommend the usual basic troubleshooting:
    1) Repair Permissions in Disk Utility, then reboot.
    If that doesn't work,
    2) Re-apply the latest Combo Update in safe mode (boot while holding shift).
    http://support.apple.com/kb/DL1048

  • Xcode 3/Interface Builder - Adding classes to NIB file doesn't work

    I'm attempting to learn Objective-C and Cocoa GUI through Apple's "Currency Convertor" tutorial. I'm currently at the "Add the ConverterController Class to Your Nib File" step, and I add ConverterController.h to the Interface Builder project (both by Read Class Files and dragging) and... nothing happens. The tutorial clearly states that the class should appear as a new icon in the MainMenu.nib window. I've tried researching this problem, and it appears to be quite common, however every fix isn't really a fix at all. They all involve using the Identity Inspector for something, which appears very complicated, and is otherwise uncovered in the tutorial. It occurs to me that anyone knowing enough to be able to use this fix wouldn't be reading this tutorial, thus making such answers moot. Any help anyone could provide on this issue would be appreciated.

    The tutorial you linked to should work fine except that they've just got the illustration (Figure 5-3) in the wrong place.
    The placement of that illustration implies that you should see the instance of your class in the MainMenu.nib window right after doing step 2 (where you read your class file). But that's not really true. In reality it's step 3 that gets you the blue box in the MainMenu.nib window and steps 4 and 5 that will transform it from an "Object" into a "ConverterController". Steps 3, 4 and 5 are exactly what Thomvis suggested that you do earlier.
    Steve

  • Class or Interface could not be loaded error on standard components

    I am trying to learn how to use Event Listeners. I created a
    TextInput field on my screen. In action script I have:
    var my_ti:TextInput;
    var enterHandler:Object = new Object();
    enterHandler.enter = function(e:Object):Void{
    trace("entered field");
    my_ti.addEventListener("enter", enterHandler);
    When I test the movie, I receive the error:
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: The
    class or interface 'TextInput' could not be loaded.
    var my_ti:TextInput;
    Any tips on fixing this would be greatly appreciated. All
    references that I have found to this error message have to do with
    paths. Given that this is a standard component, I don't know why it
    would be failing or what path to add, if that is indeed the
    problem.
    TIA

    You have the .fla and .as saved in the same file? Or the same folder?
    Also you will notice that you have
    class ship extends MovieClip
    But it looks like for your symbol you have given it a defintion of Ship. (Caps matter!)
    Your code should be capitalized, as should the name of the Ship.as file. You will notice that the Flash classes all start with a cap and that instances start with lowercase letters. You don't have to do this, but it makes it easier to know what is what.
    As a recommendation I would recommend the book by Keith Peters, Making things move. And also unless you have an overwhelming need to learn AS2, I would recommend skipping it and moving right to AS3.

  • 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

  • UITableViewCell and the Interface Builder

    I'm trying to use the Interface Builder to create a UITableViewCell but am having problems.
    I can create the UITableViewClass in my .xib file, connect the reference outlet and reuseIdentifier using the inspector. The problems occurs when I try and render the cell with this method...
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    Since the interface builder creates the TableViewCell automatically, I should be able to call...
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"priceCell"] autorelease];
    ..from inside the tableView:cellForRowAtIndexPath method and get that cell instance. But none of changes (Color, accessory view, etc...) I made to the table view come through.
    Has anyone got UITableViewCells created in the interface builder to work?

    Just an update to inform people of some of my findings.
    I had originally, before gkstuart's post, had added a UITableViewCell instance as a child of my view in IB. I then tried to use the cell via an IBOutlet in the UITableView in my view. This is when I was getting a completely blank screen when running my application. I then adopted gkstuart's idea and created a cell factory class, but without thinking, I used the same cell instance on each call to my 'newCell' method. Once I updated the 'newCell' method to load the nib file on each call to 'newCell' everything seems to work fine. As a note, the nib file loaded by 'newCell' is a simple nib file containing only my custom cell definition. It does not contain any views. Gkstuart's method of loading custom cells is unfortunate, because you can't seem to use the reusable cell theory when working with cells defined in IB. This is obviously something that needs work on Apple's side.
    As a test, I removed my custom cell definition from my original view nib. I then added a new top level instance of UITableViewCell, by dragging the UITableViewCell item to the window with the File Owner icon. After updating the custom cell definition with the appropriate class and outlets, I tried my original method again. I no longer get a completely blank screen, but it still doesn't work right. I now get a single cell in my table view, which happens to be the last cell in the list. When looking at it with the debugger, dequeueReusableCell never returns my cell instance so I am reusing and returning the same cell for each call to 'cellAtIndexPath'. I tried to manually call the cells 'prepareForReuse' method but this didn't seem to have any affect.
    So at this point, I am going to continue with the cell factory methodology until Apple either fixes the current problem or informs people on the proper way to use IB with custom UITableViewCell's.
    As a side note, I am going to start blogging about my experiences with the iPhone SDK over at iphonesdktrialsandtribulations.blogger.com.

Maybe you are looking for

  • How to insert an username from the login page to the form page

    Hi friends, I created one database apex application in which it consist of three pages... 1)login page----->1 2)form page along with report page(in same page) i.e. i created a report region within a form region 3)form page(this page appears when i cl

  • Moving standard reports to XML Publisher

    Customer wants to use XML Publisher features for the Standard reports. He would like to attach custom templates for the PL/SQL standard reports. If I understand correctly we can get XML output for reports written in Oracle Reports(OR) by setting form

  • Can we call sceen of one program into another?

    Hi ABAPers,   I wish to know whether, is it possible to call the screen of one program through another program? I know, calling a subroutine of a program from another is possible but i want to know whether calling screen of one program from another i

  • Classic BADi not being called

    Hello Experts... Your kind and expert advice is deeply appreciated... We had implemented a BADi in CRM4.0 and that is being called and working alright. We are now upgrading CRM4.0 to CRM7.0. With this change classic BADis is not being called. Differe

  • Columns, columns, columns

    I have the problem of being unable to print in colums. I mean those double columns where the two columns are next to to each other printed with the wider side of the paper being at the bottom. I dont know how the **bleep** to explain that and the pri