tags:

views:

25

answers:

4

Using IB, I have dropped an NSView (menuView) inside another.

I have set up my outlet and connected it to menuView.

I thought: " [self.menuView setHidden:NO] " would unhide it but it seems not to be working.

What else do I have to do?

A: 
menuView.hidden = NO;

maybe?

Thomas Clayson
That's just different syntax for the same code the poster listed.
samkass
+1  A: 

Have you verified that menuView is connected (NSLog() it before showing it), and that it's actually got some content?

Ben Gottlieb
If I don't set it to hidden in IB it displays in all its glory.
Oliver
the view in IB shows... but have you connected menuView the variable from your code to the view in IB is what Ben's saying.
Thomas Clayson
I've checked and the connections are definitely there in IB.I've tried " NSLOG (@"%@",self.menuView) " (not sure if that's correct... I'm new to this) and I get "null".
Oliver
....I set up an IF statement to check if the object was NULL. Turns out it is.
Oliver
connections aren't right then.
Thomas Clayson
+2  A: 

Is the IB view object connected to the menuView variable? Otherwise modifying menuView will be a no-op. I would run it in the debugger and make sure menuView isn't null at the setHidden call. If it is, go back to IB and be sure to connect the view up to the outlet.

samkass
A: 

Let's call the object with the connected outlet Fred.

You instantiated Fred in the nib, right?

And you have Fred loading the nib, right?

If the answer to either of those two questions was “no”, then disregard this answer.

If the answer to both of them was “yes”, then continue reading.

That's wrong. Fred should do only one of these two things. Chances are, you meant to make Fred the File's Owner, and hook up the connection there. The extra Fred you created in the nib is just that—an extra Fred, second to the Fred that loaded the nib. You have two Freds, and the one you have reporting the connection (in response to an action message, I'm guessing) is not the one whose outlet you connected to the menu view.

Kill off the Fred in the nib, leaving only the Fred that loads the nib. In the nib, declare the File's Owner as being of Fred's class, and in Fred's implementation, make sure that you are the File's Owner when you load the nib.

If you're using NSWindowController to load it, you need to pass yourself as owner explicitly; otherwise, the NSWindowController is the owner. Since you want Fred to be the owner, you need to tell the window controller that when you instantiate it. The alternative is to use NSBundle to load the nib directly, without an intervening window controller.

Peter Hosey