IBOutlets and IBActions, some working, some not

Discussion in 'Mac Programming' started by BadWolf13, Feb 19, 2012.

  1. macrumors 6502

    Joined:
    Dec 17, 2009
    #1
    Hey guys, got a weird one here that I can't figure out. I've got a custom view XIB file, loading into the program using:

    Code:
    	[NSBundle loadNibNamed:@"Basic" owner:self];
    
    	[window setContentView:basicView];
    
    Now the view loads, and displays just fine. However, the problem occurs when fetching information from the display, or sending information to the display. Some of it works, some of it doesn't. For instance, in this section of code:

    Code:
    	} else if (shapeButton.indexOfSelectedItem == 1) {
    		[dim1Label setStringValue:@"Width:"];
    		[dim2Label setHidden:YES];
    		[dim2Field setHidden:YES];
    
    The program recognizes that shapeButton.indexOfSelectedItem does equal 1(or whatever the value is), but doesn't have any effect on the label and textField. I've checked my XIB file, and all the connections are there, but the code just isn't making the connections.

    Anyone got any ideas what's wrong here?
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    Run your program. Set a breakpoint at the if. When the breakpoint is hit, are any or all of dim1Label, dim2Label, dim2Field null?

    You can discover this using NSLog, too, but if you don't know how to use the debugger to set breakpoints and inspect variables, now's a good time to learn.
     
  3. thread starter macrumors 6502

    Joined:
    Dec 17, 2009
    #3
    There are no nulls in any of the IBOutlets.
     
  4. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    So how do you know that?

    You're very sparse with details. Your code isn't working because you are doing _something_ wrong, and most likely it is some area in the code that you think is perfectly fine.
     
  5. thread starter macrumors 6502

    Joined:
    Dec 17, 2009
    #5
    Yeah, I just figured out the problem. I've got 3 custom views, and they're swappable within the program. Some of the IBOutlets, like the three that I mentioned, exist in all 3 views. The problem I'm doing is in the applicationDidFinishLaunching where I load all 3 views from their XIB files, and thus the outlet in the code is only pointing at the last XIB loaded.

    My plan at this point is to load only the currently active view, and release previous view from memory.
     

Share This Page